Редагувати

How to: Create a connection from the Power Apps CLI

Use the Power Apps CLI to find connectors and create a connection without leaving your terminal or opening Power Apps.

Prerequisites

An initialized Power Apps code app. See Quickstart: Create a code app by using the Power Apps CLI.

Step 1: List available connectors

Run the commands in this article from the root of your code app project.

Use pa connector list command to find the connectors available in the Power Platform environment configured for your code app:

pa connector list [--search <term>] [--json]

The environment is set in power.config.json when you run pa app init.

In an interactive terminal, results appear in pages of 20 rows. Press Enter to show the next page. Press Esc or Q to exit. When you redirect the output or include --json, the command returns the complete list. Learn more about the output options for the pa connector list command

List connectors examples

List all available connectors:

pa connector list

Search for connectors:

pa connector list --search teams

Return the connector list as JSON:

pa connector list --json

Step 2: Create the connection

Use pa connection create to create a connection in the environment configured for the code app:

pa connection create --connector <connector-id> [--display-name <name>] [--json]

Create connectors examples

Create an Office 365 Outlook connection:

pa connection create --connector shared_office365

Create a Microsoft Teams connection with a custom display name:

pa connection create --connector shared_teams --display-name "My Teams"

Create a connection and return the result as JSON:

pa connection create --connector shared_office365 --json

When the command succeeds, it returns the connection ID. Use the connection ID when you add the connector as a data source to the code app.