How to Set Connection References in a Deployment Settings File
When you import a solution in Power Apps, it asks which connection each connection reference should use. pac solution import can't ask, so you answer in advance, in a deployment settings file: one ConnectionId per reference.
A connection reference is the solution object that says which connector an app or a flow uses, without naming anyone's sign-in. Each environment points it at one of its own connections (How to Create a Connection Reference in a Solution in Power Apps). Microsoft's Pre-populate connection references and environment variables for automated deployments describes the file this guide fills: "use the deployment settings file (JSON) to store the information, and pass it as a parameter when importing the solution."
The example is a managed solution, How-to Examples, with one flow, Get My Name, which runs the Office 365 Users action Get my profile (V2) through its own connection reference, Office 365 Users HowtoExamples-251b7. It's installed into another environment, where an Office 365 Users connection already exists.
Prerequisites
- The Power Platform CLI, signed in to the environment you're installing into (Microsoft's install instructions). Check it with
pac env who. - A working connection for each connector in that environment, owned by you or shared with you.
Step 1: Create the Settings File
pac solution create-settings reads the solution zip, offline, and writes a JSON file with an empty value for everything the import would ask for:
pac solution create-settings --solution-zip HowtoExamples_1_0_0_1_managed.zip --settings-file howto.settings.json
Extracting Dataverse connection references and/or environment variables from: /Users/you/how-to/HowtoExamples_1_0_0_1_managed.zip
Deployment settings file created: /Users/you/how-to/howto.settings.json
{
"EnvironmentVariables": [],
"ConnectionReferences": [
{
"LogicalName": "dewiride_sharedoffice365users_251b7",
"ConnectionId": "",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_office365users"
}
],
"CopilotAgents": []
}
Each connection reference has three values:
| Key | What it is | Change it? |
|---|---|---|
LogicalName | The reference's Name in the solution | No |
ConnectionId | The connection to use in this environment | Yes: this is what you fill in |
ConnectorId | The connector the reference is for | No; use it to find the right connection |
EnvironmentVariables is empty here because the solution has none. For a solution that has some, see How to Set Environment Variable Values When Importing a Solution.
Step 2: Find the Connection's ID
List the environment's connections and look for the one whose API Id matches the ConnectorId (How to List Connections with pac connection list):
pac connection list | grep office365users
shared-office365user-00000000-0000-0000-0000-000000000000 admin@example.com /providers/Microsoft.PowerApps/apis/shared_office365users Connected
The first value on the line is the connection's ID. Make sure its Status is Connected.
Step 3: Fill in the ConnectionId
Open the settings file in a text editor and paste the ID between the quotes of ConnectionId. Leave everything else as it is:
{
"EnvironmentVariables": [],
"ConnectionReferences": [
{
"LogicalName": "dewiride_sharedoffice365users_251b7",
"ConnectionId": "shared-office365user-00000000-0000-0000-0000-000000000000",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_office365users"
}
],
"CopilotAgents": []
}
A solution with several references gets one ConnectionId each.
Step 4: Import with the Settings File
pac solution import --path HowtoExamples_1_0_0_1_managed.zip --settings-file howto.settings.json
Connected as admin@example.com
Connected to... Overtime Timesheet Demo
Solution Importing...
Solution Imported successfully.
It took 28 seconds. --path is the solution zip and --settings-file the file from Step 3; the command imports into the environment the profile has selected.
Step 5: Check the Result in Power Apps
Open the imported solution in Power Apps. The flow is there and On, with its connection reference:
![]()
Every connection reference I've seen says Off in that column, so look at its connection instead. In a managed solution the reference's name can't be selected. Open it from the environment's Default Solution → Connection references instead. Its Connection is the one from the settings file:
![]()
Close the panel without saving.
Build the Solution with Its Own Reference
The settings file can only fill references that are in the zip. When I added Get my profile (V2) to the flow, the designer didn't create a reference in my solution: it reused one that already existed in the environment, from another solution. The action's ⋮ menu showed it under Other connection references. + New connection reference in the same menu created a reference in my solution, and also opened a sign-in window for a brand-new connection, which I closed. I opened the new reference in my solution, set its Connection to my existing Office 365 Users connection, and then chose it in the action's menu, before exporting. The exported zip held the reference, and create-settings listed it.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Taking a connection ID from another environment | The import can't use it | Run pac connection list against the target environment |
| Copying the connection's Name | A display name isn't an ID | Copy the Id |
Changing LogicalName or ConnectorId | They no longer match the solution | Change only ConnectionId |
| A flow whose action uses another solution's reference | That reference isn't in your zip | Check the action's ⋮ menu before you export |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
ConnectionReferences is empty | The solution has no references of its own | Add them to the solution, and export again |
| The import fails on a connection | Microsoft's article: the connection must be usable by the reference's owner | Use your own connection, or one shared with you |
FAQ
Where else can I find a connection ID?
Microsoft's article suggests opening the connection in Power Apps under Connections and reading its ID from the page's address. pac connection list shows them all at once.
Can one file hold both connections and environment variables?
Yes. create-settings writes both sections, and a solution with both gets both filled in the same file.
Should I keep the filled file?
It holds IDs from one environment, not passwords. Keep one file per environment you install into, for example in source control, as Microsoft's article suggests.
Conclusion
pac solution create-settings gives you a file with one entry per connection reference. Fill each ConnectionId with an ID from pac connection list whose API Id matches the ConnectorId, then pac solution import --settings-file. The flow arrives with its connection set and turned on.
Additional Resources
- Pre-populate connection references and environment variables for automated deployments: the file's format and validation.
- pac solution:
create-settingsandimport.
