How to Deploy PowerApps Solutions Using Azure DevOps

Have you ever wondered how you can use Azure DevOps to build and release pipelines to automate PowerApps deployments? 

In this blog, we will look at how easy it is to use Power Platform Build Tools to deploy PowerApps solutions. The aim  is to present a starting point for implementing DevOps processes. 

Source Control 

In any basic DevOps process, we must first ask where our source of truth is. The same applies to Dynamics 365 PowerApps solutions. Can our DEV environment be wiped and provisioned again? 

For that to happen, our solution must be in a repo in DevOps, so let’s see how we can do that. 

 

Learn more about our DevOps Services!

 

Pre-Requisites 

  1. Azure DevOps 
  2. Power Platform Build Tools Power Platform Build Tools (1.0.41) – Visual Studio Marketplace 
  3. Multiple Dynamics 365 PowerApps instances to simulate DEV/UAT/PRD 

Solution Customizations 

To keep things simple, I have created a new solution, Account Customizations to customize my account entity/table. I have also created a new attribute/column called strategic account, and the data type is two options/Yes/No and placed this field on the main Account form. 

Repo in Azure DevOps 

Next, I have  created a project in Azure DevOps called DYN365ALM. I will add my repo, build, and release pipelines to this project. 

The report will contain the solution in its unpacked form. This will help review and merge changes when someone checks in, runs the build pipeline, and creates a Pull Request. Eventually, the solution will deploy via a release pipeline. 

Build Pipeline 

Please note that I have  created a service connection using a service principal to connect with Dynamics 365 PowerApps as an Application User. If you need additional information on how to do that, please read the following articles: 

  1. Tutorial: Register an app with Azure Active Directory (Microsoft Dataverse) – Power Apps | Microsoft Docs 
  2. Manage application users in the Power Platform admin center – Power Platform | Microsoft Docs 

We will  create two build pipelines. The first pipeline would extract the unmanaged solution, unpack it, and check-in in the repo. Once the solution is unpacked, it could be used to create a PR, and then merge the changes to be imported in a Build environment or SIT environment. 

The second pipeline would be used to pack the merged change, import it in the SIT environment and export a managed solution to be released for production. 

 Here is how the first pipeline looks. I have created a SolutionName variable to control which solution needs to be worked on. 

Export Unmanaged 

Export Unmanaged

YAML:

pool: 

name: Azure Pipelines 

variables: 

SolutionName: ‘AccountCustomizations’ 

steps: 

task: microsoft-IsvExpTools.Pow[email protected]0 

displayName: ‘Power Platform Tool Installer ‘ 

inputs: 

    PowerAppsAdminVersion: 2.0.137 

    CrmSdkCoreToolsVersion: 9.1.0.90 

 

task: microsoft-IsvExpTools.Power[email protected]0 

displayName: ‘Power Platform Export Solution ‘ 

inputs: 

    authenticationType: PowerPlatformSPN 

    PowerPlatformSPN: CRM967032 

    SolutionName: ‘$(SolutionName)’ 

    SolutionOutputFile: ‘$(Build.ArtifactStagingDirectory)\$(SolutionName).zip’ 

 

task: microsoft-IsvExpTools.Power[email protected]0 

displayName: ‘Power Platform Unpack Solution ‘ 

inputs: 

    SolutionInputFile: ‘$(Build.ArtifactStagingDirectory)\$(SolutionName).zip’ 

    SolutionTargetFolder: ‘$(Build.SourcesDirectory)\$(SolutionName)’ 

 

script: | 

   echo commit all changes 

   git config user.email “[email protected] 

   git config user.name “Automatic Build” 

   git checkout main 

   git add –all 

   git commit -m “solution init” 

   echo push code to new repo 

   git -c http.extraheader=”AUTHORIZATION: bearer $(System.AccessToken)” push origin main 

    

displayName: ‘Command Line Script’ 

Import to Build Env and Export Managed 

Next, we need to import the unmanaged customizations to a Build or SIT environment. 

YAML

YAML: 

pool: 

name: Azure Pipelines 

variables: 

SolutionName: ‘AccountCustomizations’ 

 

steps: 

task: microsoft-IsvExpTools.Pow[email protected]0 

displayName: ‘Power Platform Tool Installer ‘ 

inputs: 

    PowerAppsAdminVersion: 2.0.137 

    CrmSdkCoreToolsVersion: 9.1.0.90 

 

task: microsoft-IsvExpTools.P[email protected]0 

displayName: ‘Power Platform Pack Solution ‘ 

inputs: 

    SolutionSourceFolder: ‘$(Build.SourcesDirectory)\$(SolutionName) ‘ 

    SolutionOutputFile: ‘$(Build.ArtifactStagingDirectory)\$(SolutionName).zip’ 

 

task: microsoft-IsvExpTools.Power[email protected]0 

displayName: ‘Power Platform Import Solution ‘ 

inputs: 

    authenticationType: PowerPlatformSPN 

    PowerPlatformSPN: CRM907570 

    SolutionInputFile: ‘$(Build.ArtifactStagingDirectory)\$(SolutionName).zip’ 

 

task: microsoft-IsvExpTools.PowerPlatform-Build[email protected]0 

displayName: ‘Power Platform Publish Customizations ‘ 

inputs: 

    authenticationType: PowerPlatformSPN 

    PowerPlatformSPN: CRM907570 

 

task: microsoft-IsvExpTools.Power[email protected]0 

displayName: ‘Power Platform Export Solution ‘ 

inputs: 

    authenticationType: PowerPlatformSPN 

    PowerPlatformSPN: CRM907570 

    SolutionName: ‘$(SolutionName)’ 

    SolutionOutputFile: ‘$(Build.ArtifactStagingDirectory)\$(SolutionName)_managed.zip’ 

    Managed: true 

 

task: [email protected] 

displayName: ‘Publish Artifact: drop’ 

To ensure CI/CD, I have enabled trigger for managed build to trigger on completion of unmanaged export pipeline 

image005

Now that we have our managed solution exported and checked-in in the repo, we will proceed with our release pipeline for production deployment. 

Start with a blank release pipeline and select the artifact from the export managed build pipeline. 

Next, add the following steps to the release stage for production deployment. 

Release Pipeline 

image007

Let’s trigger the build pipeline and see the results: 

image009
image010
image011
image013

And in Dynamics 365 production organization, we have our managed solution with the new Strategic Account field deployed. 

image015
image017

Conclusion 

In this blog we discussed from scratch how we can create build pipelines with Dynamics 365 PowerApps and Azure DevOps. Furthermore , we also discussed how we can create a build release, and use release pipelines to deploy the solution to a production environment.

That’s how simple it is to get started with Azure DevOps, and Power Platform Build Tools to create build and release pipelines and introduce some initial form ALM.  

Leave a Reply

Your email address will not be published.