- Azure DevOps Repositories can be used as Source Control for Power Platform Solutions
- CI/CD can be implemented using Azure DevOps Pipelines
- We can use Microsoft Power Platform Build Tools to automate common build and deployment tasks related to apps built on Microsoft Power Platform . There are 2 versions of Build tools – older based on PowerShell and latest version based on Power Platform CLI
To implement CI/CD process with Azure DevOps Pipelines, we can store the Power Platform solution in the source control. There are two main Paths –
- Export the unmanaged solution and place it as unpacked in the source control system. The build process imports the packed solution as unmanaged into a temporary build environment , then export the solution as managed and store it as a build artifact in your source control system.
- Export the solution as unmanaged and also export the solution as managed, and place both in the source control system.
Fig 1
In this article, we will show the steps to achieve the Option above 2 above, and Fig 1 depicts the process.
Create source and target environments. Both should have Dataverse database enabled. Create an unmanaged Solution in the source environment
- Create Azure Dev Ops Organization
- Create the Project within it
- Create the Repository to hold the source code
- Install Microsoft Power Platform Build Tools into your Azure DevOps organization from Azure Marketpl…
- Request parallelism if using Azure DevOps pipelines for first time using the link https://aka.ms/azpipelines-parallelism-request.
- Within the Project, navigate to Project Settings> Repositories>Security Tab. Under user Permissions, make sure that for Project Collection Service Accounts under Azure DevOps Groups and
Build Service under users Contribute Permission is set to allow
Create Azure AD App Registration
- Go to https://portal.azure.com
- Search for App Registration, click New Registration
- Provide the name, keep other fields with default value and click Register
- Once the App is created, go to API Permissions, click Add a Permission>Select Dynamics CRM>Add Permission >Grant Admin Consent for
- Go to Overview>Client credentials>New Secret. Copy the value into a notepad as this will be needed later and you won’t be able to get it once navigate away from this page.
- Come back to overview, and copy the Application (client) ID and Directory (tenant) ID in the same notepad. You will need these 3 values while creating service connection
Add the service principal as App user into Power Platform source and destination environment.
- Go to Power Platform Admin Center>Environments
- Select your Source Environment
- From right navigation, Users >See All>App users list
- Click New App user>search for the App created in Previous step>Add it and provide System Customizer or System Administrator role.
- Repeat all the steps above for the destination environment
Create Service Connection with Application ID and Client Secret
- Go to your Azure DevOps Project, click Project Settings
- Under Pipelines, click Service Connections >New Service Connection>Select Power Platform
- Select Authentication method as Application ID and client secret
- Go to make.powerapps.com> Select your Source environment >Go to Settings>Session details>copy the Instance url and paste it under Server Url
- Paste Tenant Id, Application Id and Client Secret as saved earlier
- Save the Service Connection with the name “Dev Service Principal”
- Follow the steps ii to vi above , this time get the destination environment url, create the service connection and save as “Prod Service Principal”
Create Pipeline – Export from Source
- From the left navigation within the Project, click on Pipelines >New Pipeline>Use the Classic Editor
- Select the Source as Azure Repos Git, select your Project, Repository and Branch and click continue
- Under select template, start with Empty job
Click Agent Job 1 and make sure Allow Scripts to access OAuth token is checked
- Add the task Power Platform Tool Installer with task version 2
Add the task Power Platform Export Solution. We are adding the task to export the solution as unmanaged here
For Service Connection, Select Service Principal> Select Dev Service Principal from Dropdown
Provide your Solution Name (not the display name)
Solution output file name $(Build.ArtifactStagingDirectory)
Uncheck export as Managed Solutin
- Copy the above task . This time we are exporting managed solution. Keep all settings same, only check the box Export as Managed solution and the Solution Output file name to $(Build.ArtifactStagingDirectory)
_managed.zip
- Add the task Power Platform Unpack Solution
Solution Input File -$(Build.ArtifactStagingDirectory)
Target Folder to Unpack Solution – $(Build.SourcesDirectory)
Type of Solution – Both
- Add a task Command Line script, and paste the below script
echo commit all changes
git config user.email “
git config user.name “
git checkout -B main
git add –all
git commit -m “code commit”
git push –set-upstream origin main
- Save and queue the Pipeline and wait it to be finished
- Check the repository for the unpacked source code
Create Deployment Settings File
- Open Visual Studio Code
- Install PAC CLI
- Run the below command to export the solution in your local machine
pac solution export –name
- Run below command to create Deployment Settings file
pac solution create-settings –solution-zip .
- Update values in the Deployment Settings file for the target environment
- In the Repository, create a Folder named Settings, create a file
.json within it, copy the text from the Deployment Settings File
Create Build Pipeline
- Create a new Pipeline with Classic Editor>Empty Job
- Add the task Power Platform Tool Installer
- Add a task Power Platform Pack Solution
Source Folder of Solution to Pack -Select Folder by clicking 3 dots
Solution Output File –
Type of Solution -Both
- Add a task -Copy Files
Source Folder -Settings
Contents -**
Target Folder – $(Build.ArtifactStagingDirectory)
- Add a task Publish Artifact
Path to publish – $(Build.ArtifactStagingDirectory)
Artifact Name – drop
- Save and Queue the Build Pipeline
Create Release Pipeline
- From Left navigation, click Releases >New Release Pipeline >Start with Empty Job
- Add the Artifact created in the Build pipeline
Select your project and build pipeline
Source alias -drop
- Under Stages>Stage 1>Click Job
- Add the task Power Platform Tool installer
- Add the task Power Platform Import Solution
- Service Connection – Select the service connection you created for Prod.
- Solution Input File – Select clicking 3 dots, select the managed zip file for Prod
- Check Use Deployment Settings File and select the Deployment settings file by clicking 3 dots.
- For Prod, under Advanced, check Import Managed Solution
- Save the pipeline and create a Release
- Check the Solution has been deployed properly to Production
3b. Create Azure DevOps Pipelines with Managed Identity
- Create VMScaleSet and assign Managed Identity
- Create Self hosted Agent pool and point to the VMscale set
- Add the managed identity as App user into Power Platform source and destination environment.
- Create Service Connection with managed identity.
- Create Build Pipelines- Export from Source and Build Solution. Create Release Pipeline – Deploy to Destination . Use previously created self-hosted agent pool.
Please follow this Blog for detail steps .