When I published this blog post about Power Automate Deployment (manual), the great – Bill Blancett gave suggestions regarding the solution’s import setting file that we can use if we want to import the solution using CI/CD or using Power Platform Tools CLI (you need to make sure you install this on your machine):

TL/DR from my blog post, when I import the solution using “pac solution import” command, the solution is imported successfully. But you will get an error because the connection references are not being defined. So, here is the tutorial regarding Pre-populate connection references and environment variables for automated deployments!
By my observation, here is what we gonna do:

The concepts are very clear to me:
The environment variable can differ from 1 environment to another. When we define the default value and the current value, the solution will contain the information. So, when we import the solution without the solution’s setting file, the value will remain as it is.

Connection reference is different from the environment variable. Even though the solution for the demo contains the connection reference, you will not find any connection string or anything in the zip files (the export file).

The connection reference will become a definition only:

As you can see from the image above, the left-hand side is the connection reference’s definition (which doesn’t contain any information regarding the environment/user/password). While the right-hand side is the demo flow that I created. In the first couple of lines, it will show the connection reference selected.
Up until now, if you are importing manually using the command “pac solution import –path solution.zip” (you need to make sure you run the auth command first), the connection reference will be empty which leads to getting the error when the Flow is triggered (if you realize the connection reference name is different, it is because I changed it purposely in order to get the below screenshot):

While the environment variable will have the same values as the source environment:

So far, here is the conclusion:
- Environment variable values (default value + current value) will still be the same as the source information.
- Connection reference if we never import before (with the same name) will result as empty connection reference (like the above screenshot). But if you already imported the connection reference before + set the connection reference, it will not be empty.
Create solution’s setting file
Finally, we go to the steps to create the solution’s setting file. In my testing, you need to make sure the solution that you will use contains the environment variable/connection reference. If you don’t, when you run the below command will result in empty array values only (for EnvironmentVariables and ConnectionReferences properties). You only need to run the below command:
pac solution create-settings --solution-zip .\DemoFlow_managed.zip --settings-file .\DemoFlowTemmy2.json
It will generate a DemoFlowTemmy2.json file:
{
"EnvironmentVariables": [
{
"SchemaName": "dev_DemoConnection",
"Value": ""
}
],
"ConnectionReferences": [
{
"LogicalName": "dev_sharedcommondataserviceforapps_a4c3e",
"ConnectionId": "",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"
}
]
}
As you can see, we need to fill in the information for line number 5 and 11 with the value that we need for the Environment that we want to target. For the Environment variable (as usually is just a text) is much easier. You only need to update it using the value that you want:
{
"EnvironmentVariables": [
{
"SchemaName": "dev_DemoConnection",
"Value": "{\"Message\":\"From Environment 2\"}"
}
],
...
}
For the connection reference, you need to go to make.powerapps.com > select the environment that you want to add > Dataverse > Connections > you can create/select based on the connection type you need (for the demo, I’ll just use Dataverse connector):

Once created, you can click the connection that you just created and you can see the below information:

You need to copy the connection id from the URL and paste it to the setting file JSON:
{
"EnvironmentVariables": [
{
"SchemaName": "dev_DemoConnection",
"Value": "{\"Message\":\"From Environment 2\"}"
}
],
"ConnectionReferences": [
{
"LogicalName": "dev_sharedcommondataserviceforapps_a4c3e",
"ConnectionId": "8a47cefd47104b129ff7a65f0ec05268",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"
}
]
}
Once done, you can save the file and you are ready to import using the below command:
pac solution import --path .\DemoFlow_managed.zip --settings-file .\DemoFlowTemmy2.json
Once finished, you can check again the environment variable and the connection reference value:

Happy CRM-ing!