Using Power Platform CLI to Set Connection Reference during Solution Import

·

2 min read

For projects that do not have Azure pipelines to import solutions and set connection references via pipelines, the pac cli commands come in as a very useful alternative by providing the ability to set connection references.


Useful links to get started

Getting started with Power Platform CLI
Pac solution commands
Generating deployment settings file

Step 1: Authenticating to Dynamics 365

C:\>pac auth create --url <url of the environment>

Step 2: Export solution from the source environment

pac solution export --path <path to export> --name <solution name> --managed true

Step 3: Generating settings file to set connection references

C:\exportdemo>pac solution create-settings --solution-zip <path to solution file> --settings-file <name of the file>.json

Step 4: Go to the target instance and create a connection

In this example, I have created a Dataverse connection using a service principal
Can create a temp solution with right prefix and create a demo flow using a service principal, once the connection is created this flow can be deleted

Go to make.powerapps.com and look for connections and copy the connection id from the URL

Step 5: Updating deployment settings file with connection from the target environment

Step 6:

Repeat step 1, just change the url to target dynamics 365 instance and perform the below

Import the solution to the target environment as managed and supply the settings file in the command

pac solution import --path <path of the solution>.zip --settings-file <path of the file>\settings.json

Review the connection in the target environment and it should be set to the service principal connection set on the deployment settings file.