Sharing Connection References with Service Principal in Azure DevOps for Power Platform ALM
Introduction
When setting up your Azure DevOps pipeline for deploying a Power Platform solution, you may encounter an error message if your solution relies on connection references.
The reason given was : An unexpected error occurred.
This generic message does not provide much help and can occur for multiple reasons. In my scenario, it was related to the connection references in the target environment not being shared with the service principal.
The settings file for the Power Platform solution contains the following connection references:
{
"EnvironmentVariables": [],
"ConnectionReferences": [
{
"LogicalName": "fr_cc_groups",
"ConnectionId": "",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_office365groups"
},
{
"LogicalName": "fr_cc_officeusers",
"ConnectionId": "",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_office365users"
},
{
"LogicalName": "fr_cc_outlook",
"ConnectionId": "",
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_office365"
}
]
}
Follow these steps in the target environment to ensure the deployment is successful:
- Create the Connections: Navigate to the target environment and create the necessary connections. Replace
c4f1c161-0000-0000-0000-bb36fcdb9da0
with your environment ID in the URL: PowerApps Connections.
- Share the Connection with the Service Principal: If the connection is not shared with the service principal used in the ALM, the unexpected error may occur. Click on the ellipsis (…) next to the connection and select Share.
- Test Locally: It’s a good idea to test the deployment locally using the PAC CLI command
pac solution import
.
pac solution import --path "C:\settings\test_managed.zip" --async true --force-overwrite false --publish-changes true --skip-dependency-check false --convert-to-managed true --max-async-wait-time 60 --activate-plugins true --skip-lower-version false --settings-file "C:\settings\settings-test.json"
If deployment is successful via PAC CLI and failing via the Azure DevOps pipeline, it could be due to the connection reference not shared with the service principal.
Hopefully it all is set up correctly, the deployment will be successful.
References
Pre-populate connection references and environment variables for automated deployments