# @microsoft/power-apps-cli A command-line interface for managing Power Apps code apps. This CLI enables you to initialize, develop, and publish Code Apps directly from your terminal. > **Note:** This CLI is designed to be used alongside the `@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. ## Installation ```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 --display-name "My App" --environment-id 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. If a config file is not present yet, defaults to `prod`. Use the `--cloud` CLI flag to override. ## Global Options | Option | Alias | Description | | ------------------- | ----- | ----------------------------------------------------------------------- | | `--cloud` | | Cloud instance to use (e.g., prod, test, etc.) | | `--environment-id` | `-e` | Environment ID to connect to | | `--non-interactive` | | Run in non-interactive mode (all parameters must be provided via flags) | | `--json` | | Format output as JSON | | `--no-color` | | Disable colored output | | `--help` | `-h` | Display help for a command | | `--version` | `-v` | Output the current version | ## Commands ### `init` Initialize a new Power Apps code app. ```bash npx power-apps init [options] ``` **Options:** | Option | Alias | Description | Default | | -------------------- | ----- | ---------------------------------------------- | ----------------------- | | `--environment-id` | `-e` | Environment ID to connect to | | | `--cloud` | | Cloud instance to use (e.g., prod, test, etc.) | `prod` | | `--display-name` | `-n` | Display name for the app | | | `--description` | `-d` | App description | _(empty)_ | | `--build-path` | `-b` | Build output path | `./dist` | | `--file-entry-point` | `-f` | Entry point file for the app | `index.html` | | `--app-url` | `-a` | Local URL where the app is hosted | `http://localhost:3000` | | `--logo-path` | `-l` | Path to the app logo file | `Default` | --- ### `run` 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` | | `--local-app-url` | `-l` | Local URL where the app is hosted | `http://localhost:3000` | --- ### `push` Push the code app to the Power Apps environment. ```bash npx power-apps push [options] ``` **Options:** | Option | Alias | Description | | --------------- | ----- | ------------------------------------- | | `--solution-id` | `-s` | Solution name or ID to add the app to | --- ### `add-data-source` Add a data source to the current Power Apps code app. ```bash npx power-apps add-data-source [options] ``` **Options:** | Option | Alias | Description | | ------------------------ | ----- | ------------------------- | | `--api-id` | `-a` | API identifier | | `--connection-id` | `-c` | Connection identifier | | `--connection-ref` | `-cr` | Connection reference name | | `--resource-name` | `-t` | Table or resource name | | `--dataset` | `-d` | Dataset identifier | | `--org-url` | `-u` | Organization URL | | `--sql-stored-procedure` | `-sp` | SQL stored procedure name | | `--solution-id` | `-s` | Solution identifier | --- ### `create-connection` Create a new connection for a connector. When the connector is SSO-eligible (single auth type that supports first-party login), the connection is created silently using the current user's identity. For other connectors, the CLI starts a local callback server and opens the browser to a hosted page so you can complete the auth flow interactively. In non-interactive mode, only SSO-eligible connectors are supported. > **Note:** Browser-based connection creation is currently disabled by default while it is being stabilized. To opt in, set the environment variable `POWERAPPS_CLI_ENABLE_BROWSER_CONNECTION=true`. When the variable is unset or false, connectors that require user interaction fail with a clear error directing you to . ```bash npx power-apps create-connection [options] ``` **Options:** | Option | Alias | Description | | ---------------- | ----- | ------------------------------------------------------ | | `--api-id` | `-a` | API identifier (connector ID), e.g. `shared_office365` | | `--display-name` | `-n` | Optional display name for the new connection | With `--json`, prints `{ "connectionId": "...", "displayName": "..." }` on success. --- ### `delete-data-source` Remove a data source from the Power Apps code app. ```bash npx power-apps delete-data-source [options] ``` **Options:** | Option | Alias | Description | | ------------------------ | ----- | ---------------------------------------------- | | `--api-id` | `-a` | API identifier associated with the data source | | `--data-source-name` | `-n` | Data source or table name to remove | | `--sql-stored-procedure` | `-sp` | SQL stored procedure name to remove | --- ### `list-codeapps` List all code apps in the environment. ```bash npx power-apps list-codeapps ``` --- ### `list-connection-references` List all connection references in the environment. ```bash npx power-apps list-connection-references [options] ``` **Options:** | Option | Alias | Description | | --------------- | ----- | -------------------------------- | | `--solution-id` | `-s` | Solution identifier to filter by | | `--org-url` | `-u` | Organization URL | --- ### `list-datasets` List all datasets for a connection. ```bash npx power-apps list-datasets [options] ``` **Options:** | Option | Alias | Description | | ----------------- | ----- | --------------------- | | `--api-id` | `-a` | API identifier | | `--connection-id` | `-c` | Connection identifier | --- ### `list-tables` List all tables for a dataset. ```bash npx power-apps list-tables [options] ``` **Options:** | Option | Alias | Description | | ----------------- | ----- | --------------------- | | `--api-id` | `-a` | API identifier | | `--connection-id` | `-c` | Connection identifier | | `--dataset` | `-d` | Dataset name | --- ### `list-sqlStoredProcedures` List all SQL stored procedures for a dataset. ```bash npx power-apps list-sqlStoredProcedures [options] ``` **Options:** | Option | Alias | Description | | ----------------- | ----- | --------------------- | | `--connection-id` | `-c` | Connection identifier | | `--dataset` | `-d` | Dataset name | --- ### `list-environment-variables` List all environment variables in the environment. ```bash npx power-apps list-environment-variables [options] ``` **Options:** | Option | Alias | Description | | ----------- | ----- | ---------------- | | `--org-url` | `-u` | Organization URL | --- ### `list-flows` List all solution cloud flows that are invokable from Power Apps. ```bash npx power-apps list-flows [options] ``` **Options:** | Option | Alias | Description | | ---------- | ----- | ------------------------------------------------------- | | `--search` | `-s` | Filter flows by name (case-insensitive substring match) | --- ### `add-flow` Add a cloud flow to the current Power Apps code app by flow ID. Fetches the flow metadata and swagger, updates `power.config` with connection references, and generates model services. ```bash npx power-apps add-flow --flow-id ``` **Options:** | Option | Alias | Description | | ----------- | ----- | ----------------------------------------------- | | `--flow-id` | `-f` | The unique identifier (GUID) of the flow to add | **Example:** ```bash npx power-apps add-flow --flow-id 00000000-0000-0000-0000-000000000000 ``` --- ### `find-dataverse-api` Search Dataverse actions and functions in the environment by name. ```bash npx power-apps find-dataverse-api [options] ``` **Options:** | Option | Alias | Description | | ---------- | ----- | -------------------------------------------------- | | `--search` | `-s` | Search term to filter Dataverse operations by name | **Examples:** ```bash npx power-apps find-dataverse-api --search "account" npx power-apps find-dataverse-api --search "account" --json ``` --- ### `remove-flow` Remove a cloud flow from the current Power Apps code app. Deletes the flow's connection references from `power.config`, removes the schema file, and regenerates model services. ```bash npx power-apps remove-flow [options] ``` **Options:** | Option | Alias | Description | | ------------- | ----- | --------------------------------------------------------------------- | | `--flow-name` | `-n` | The flow data source name to remove (as it appears in `power.config`) | | `--flow-id` | `-f` | The flow resource ID (GUID) to remove — same ID used with `add-flow` | Provide either `--flow-name` or `--flow-id`. **Examples:** ```bash npx power-apps remove-flow --flow-name myFlow npx power-apps remove-flow --flow-id 00000000-0000-0000-0000-000000000000 ``` --- ### `telemetry` Manage telemetry settings. ```bash npx power-apps telemetry [options] ``` **Options:** | Option | Description | | --------------------- | ----------------------------------------------------- | | `--enable` | Enable telemetry | | `--disable` | Disable telemetry | | `--show-settings` | Show current telemetry settings | | `--console-only` | Output telemetry to console only | | `--output-to-console` | Output telemetry to console in addition to sending it | --- ### `logout` 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 ``` ## License Copyright (C) Microsoft Corporation. All rights reserved.