CLI for PowerApps
npm install @microsoft/power-apps-cli@microsoft/power-apps package. It is generally not recommended to install this package separately. When you install @microsoft/power-apps, this CLI is included automatically.
bash
npm install @microsoft/power-apps-cli
`
After installation, run commands using:
`bash
npx power-apps
`
Usage
You can use the CLI in two ways:
1. Pass options directly: Provide all required options as command-line arguments.
`bash
npx power-apps init --displayName "My App" --environmentId abc-123
`
2. Interactive prompts: Simply run a command without options, and the CLI will prompt you for any required information.
`bash
npx power-apps init
# The CLI will interactively ask for display name, environment ID, etc.
`
Configuration
The CLI reads configuration from your power.config.json file:
- environmentId - Required. The environment ID to connect to. If a config file is not present yet, the CLI will prompt you to provide one.
- region - The cloud instance region. If a config file is not present yet, defaults to prod.
Global Options
| Option | Alias | Description |
| ----------------- | ----- | ----------------------------------------------------- |
| --region | -r | Cloud instance region to use (e.g., prod, test, etc.) |
| --environmentId | -e | Environment ID to connect to |
| --help | -h | Display help for a command |
| --version | -v | Output the current version |
Commands
$3
Initialize a new Power Apps code app.
`bash
npx power-apps init [options]
`
Options:
| Option | Alias | Description | Default |
| ------------------ | ----- | ----------------------------------------------------- | ----------------------- |
| --environmentId | -e | Environment ID to connect to | |
| --region | -r | Cloud instance region to use (e.g., prod, test, etc.) | prod |
| --displayName | -n | Display name for the app | |
| --description | -d | App description | _(empty)_ |
| --buildPath | -b | Build output path | ./dist |
| --fileEntryPoint | -f | Entry point file for the app | index.html |
| --appUrl | -a | Local URL where the app is hosted | http://localhost:3000 |
| --logoPath | -l | Path to the app logo file | Default |
---
$3
Run the code app locally for development.
`bash
npx power-apps run [options]
`
Options:
| Option | Alias | Description | Default |
| --------------- | ----- | --------------------------------- | ----------------------- |
| --port | -p | Port number for the local server | 8080 |
| --localAppUrl | -l | Local URL where the app is hosted | http://localhost:3000 |
---
$3
Push the code app to the Power Apps environment.
`bash
npx power-apps push [options]
`
Options:
| Option | Alias | Description |
| -------------- | ----- | ------------------------------------- |
| --solutionId | -s | Solution name or ID to add the app to |
---
$3
Add a data source to the current Power Apps code app.
`bash
npx power-apps add-data-source [options]
`
Options:
| Option | Alias | Description |
| ---------------------- | ----- | ------------------------- |
| --apiId | -a | API identifier |
| --connectionId | -c | Connection identifier |
| --connectionRef | -cr | Connection reference name |
| --resourceName | -t | Table or resource name |
| --dataset | -d | Dataset identifier |
| --orgUrl | -u | Organization URL |
| --sqlStoredProcedure | -sp | SQL stored procedure name |
| --solutionId | -s | Solution identifier |
---
$3
Remove a data source from the Power Apps code app.
`bash
npx power-apps delete-data-source [options]
`
Options:
| Option | Alias | Description |
| ---------------------- | ----- | ---------------------------------------------- |
| --apiId | -a | API identifier associated with the data source |
| --dataSourceName | -n | Data source or table name to remove |
| --sqlStoredProcedure | -sp | SQL stored procedure name to remove |
---
$3
List all code apps in the environment.
`bash
npx power-apps list-codeapps
`
---
$3
List all connection references in the environment.
`bash
npx power-apps list-connection-references [options]
`
Options:
| Option | Alias | Description |
| -------------- | ----- | -------------------------------- |
| --solutionId | -s | Solution identifier to filter by |
| --orgUrl | -u | Organization URL |
---
$3
List all datasets for a connection.
`bash
npx power-apps list-datasets [options]
`
Options:
| Option | Alias | Description |
| ---------------- | ----- | --------------------- |
| --apiId | -a | API identifier |
| --connectionId | -c | Connection identifier |
---
$3
List all tables for a dataset.
`bash
npx power-apps list-tables [options]
`
Options:
| Option | Alias | Description |
| ---------------- | ----- | --------------------- |
| --apiId | -a | API identifier |
| --connectionId | -c | Connection identifier |
| --dataset | -d | Dataset name |
---
$3
List all SQL stored procedures for a dataset.
`bash
npx power-apps list-sqlStoredProcedures [options]
`
Options:
| Option | Alias | Description |
| ---------------- | ----- | --------------------- |
| --connectionId | -c | Connection identifier |
| --dataset | -d | Dataset name |
---
$3
List all environment variables in the environment.
`bash
npx power-apps list-environment-variables [options]
`
Options:
| Option | Alias | Description |
| ---------- | ----- | ---------------- |
| --orgUrl | -u | Organization URL |
---
$3
Manage telemetry settings.
`bash
npx power-apps telemetry [options]
`
Options:
| Option | Description |
| ------------------- | ----------------------------------------------------- |
| --enable | Enable telemetry |
| --disable | Disable telemetry |
| --showSettings | Show current telemetry settings |
| --consoleOnly | Output telemetry to console only |
| --outputToConsole | Output telemetry to console in addition to sending it |
---
$3
Log out the current user.
`bash
npx power-apps logout
`
Getting Help
To see help for any command, use the --help flag:
`bash
Global help
npx power-apps --help
Command-specific help
npx power-apps init --help
npx power-apps add-data-source --help
``