Code Apps - CLI Reference for 'pac code' commands

pac code - Reference Summary
The list of commands available through pac code are as follows:- add-data-source Adds a new datasource to the app.
- delete-data-source Deletes a data source from the current app.
- init Initializes a Code app in the current directory.
- list Lists the code apps available in the current environment.
- list-connection-references Lists connection references in the specified environment and solution.
- list-datasets Lists datasets accessible by the provided connector.
- list-sql-stored-procedures Lists stored procedures accessible by the provided SQL connection and dataset.
- list-tables Lists tables accessible by the provided connector and dataset.
- push Publishes a new version of a Code app.
- run Runs a local server for connections loading locally in the app.
add-data-source
Description: Adds a new data source to the app.
pac code add-data-source --apiId [--connectionId] [--table] [--dataset] [--storedProcedure] [--environment] [--logLevel] [--connectionRef] [--solutionId]
--apiId: The API ID of the datasource (alias: -a).
--connectionId: The connection ID of the datasource (alias: -c).
--table: The table name of the datasource (alias: -t).
--dataset: The dataset name of the datasource (alias: -d).
--storedProcedure: The stored procedure name to add (alias: -sp).
--environment: The environment URL for the data source (alias: -env).
--logLevel: The logging level for the command (alias: -l).
--connectionRef: The connection reference ID (alias: -cr).
--solutionId: The solution ID of the connection reference (alias: -s).
delete-data-source
Description: Deletes a data source from the current app.
pac code delete-data-source --dataSourceName --apiId [--storedProcedure]
--dataSourceName: The name of the data source to delete (alias: -ds).
--apiId: The API ID of the datasource (alias: -a).
--storedProcedure: The stored procedure name to remove from the app (alias: -sp).
init
Description: Initialises a Code app in the current directory. Usage instructions and arguments:
pac code init [--environment] --displayName [--description] [--buildPath] [--fileEntryPoint] [--appUrl] [--logoPath] [--region]
--environment: Specifies the target Dataverse URL or GUID (alias: -env).
--displayName: The display name of the Code app (alias: -n).
--description: The description of the Code app (alias: -d).
--buildPath: The directory of your app's build assets (alias: -b).
--fileEntryPoint: The entry point for the app to load from (alias: -f).
--appUrl: The local URL the app is running on (alias: -a).
--logoPath: The path to the logo file for the app (alias: -l).
--region: The region to host the Code app in (alias: -c).
list
Description: Lists the code apps available in the current environment.
pac code list
This command does not take any arguments.
list-connection-references
Description: Lists connection references in the specified environment and solution.
pac code list-connection-references --solutionId [--environment]
--solutionId: The ID of the solution to list connection references from (alias: -s).
--environment: The environment URL to list from (alias: -env).
list-datasets
Description: Lists datasets accessible by the provided connector.
pac code list-datasets --apiId [--connectionId]
--apiId: The API ID of the datasource (alias: -a).
--connectionId: The connection ID of the datasource (alias: -c).
list-sql-stored-procedures
Description: Lists stored procedures accessible by the provided SQL connection and dataset.
pac code list-sql-stored-procedures [--connectionId] [--dataset]
--connectionId: The connection ID of the datasource (alias: -c).
--dataset: The dataset name of the datasource (alias: -d).
list-tables
Description: Lists tables accessible by the provided connector and dataset.
pac code list-tables --apiId [--connectionId] [--dataset]
--apiId: The API ID of the datasource (alias: -a).
--connectionId: The connection ID of the datasource (alias: -c).
--dataset: The dataset name of the datasource (alias: -d).
push
Description: Publishes a new version of a Code app.
pac code push [--environment] [--solutionName]
--environment: Specifies the target Dataverse environment (alias: -env).
--solutionName: The Solution Name for the code app to associate with (alias: -s).
run
Description: Runs a local server for connections loading locally in the app.
pac code run [--port] [--appUrl]
--port: The port to run the local server on (alias: -p).
--appUrl: The local URL the app is running on (alias: -a).
Conclusion
'pac code' is an essential tool for Code App developers. It enables us to initialise, run, and publish code apps. This post provides a reference guide of the usage instructions for each command.