Skip to main content

Notifications

Detail Step-By-Step - Power Platform ALM with Azure DevOps

Introduction

 

  • 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

 

Power Platform ALM with Azure DevOps Process Flow

 

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 –

  1. 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.
  2. Export the solution as unmanaged and also export the solution as managed, and place both in the source control system.

suparnabanerje_0-1674123826749.png

 

Fig 1

 

In this article, we will show the steps to achieve the Option above 2 above, and Fig 1 depicts the process.

 

1.Setup source and Target environment

 

Create source and target environments. Both should have Dataverse database enabled. Create an unmanaged Solution in the source environment

 

2.Set up Azure DevOps

 

  1. Create Azure Dev Ops Organization
  2. Create the Project within it
  3. Create the Repository to hold the source code
  4. Install Microsoft Power Platform Build Tools into your Azure DevOps organization from Azure Marketplace
  5. Request parallelism if using Azure DevOps pipelines for first time using the link https://aka.ms/azpipelines-parallelism-request.
  6. 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 <ProjectName> Build Service <OrgName> under users Contribute Permission is set to allow

suparnabanerje_1-1674123826755.png

 

suparnabanerje_2-1674123826760.png

 

 

3a. Create Azure DevOps Pipelines with Application ID and Client Secret

 

Create Azure AD App Registration

 

  1. Go to https://portal.azure.com
  2. Search for App Registration, click New Registration
  3. Provide the name, keep other fields with default value and click Register
  4. Once the App is created, go to API Permissions, click Add a Permission>Select Dynamics CRM>Add Permission >Grant Admin Consent for <tenant>suparnabanerje_3-1674123826766.png
  5. 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.
  6.  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.

 

  1. Go to Power Platform Admin Center>Environments
  2. Select your Source Environment
  3. From right navigation, Users >See All>App users list
  4. Click New App user>search for the App created in Previous step>Add it and provide System Customizer or System Administrator role.
  5. Repeat all the steps above for the destination environment

 

Create Service Connection with Application ID and Client Secret

 

  1. Go to your Azure DevOps Project, click Project Settings.
  2. Under Pipelines, click Service Connections >New Service Connection>Select Power Platform
  3. Select Authentication method as Application ID and client secret
  4. Go to make.powerapps.com> Select your Source environment >Go to Settings>Session details>copy the Instance url and paste it under Server Url
  5. Paste Tenant Id, Application Id and Client Secret as saved earlier
  6. Save the Service Connection with the name “Dev Service Principal”
  7. 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

 

i.  From the left navigation within the Project, click on Pipelines >New Pipeline>Use the Classic Editor

ii.  Select the Source as Azure Repos Git, select your Project, Repository and Branch and click continue

suparnabanerje_4-1674123826768.png

 

iii.  Under select template, start with Empty job

suparnabanerje_5-1674123826769.png

 

 

iv.  Click Agent Job 1 and make sure Allow Scripts to access OAuth token is checked

suparnabanerje_6-1674123826770.png

 

 

v.  Add the task Power Platform Tool Installer with task version 2

suparnabanerje_7-1674123826776.png

 

 

vi.  Add the task Power Platform Export Solution. We are adding the task to export the solution as unmanaged here

suparnabanerje_8-1674123826778.png

 

 

suparnabanerje_9-1674123826789.png

 

 

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)\<SolutionName>.zip

Uncheck export as Managed Solutin

 

vii.  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)\<SolutionName>_managed.zip

 

viii.  Add the task Power Platform Unpack Solution

suparnabanerje_10-1674123826801.png

 

 

Solution Input File -$(Build.ArtifactStagingDirectory)\<SolutionName>.zip

Target Folder to Unpack Solution - $(Build.SourcesDirectory)\<SolutionName>

Type of Solution – Both

 

ix.  Add a task Command Line script, and paste the below script

 

echo commit all changes

git config user.email “<email>”

git config user.name "<user name>"

git checkout -B main

git add --all

git commit -m "code commit"

git push --set-upstream origin main

 

x.  Save and queue the Pipeline and wait it to be finished

xi.  Check the repository for the unpacked source code

 

suparnabanerje_11-1674123826803.png

 

 

Create Deployment Settings File

 

  1. Open Visual Studio Code
  2. Install PAC CLI
  3. Run the below command to export the solution in your local machine

 

pac solution export --name <solutionname> --path .\ --managed false

 

     iv.  Run below command to create Deployment Settings file

 

pac solution create-settings --solution-zip .\<SolutionName>.zip --settings-file <SolutionName>.json

    v.  Update values in the Deployment Settings file for the target environment

    vi.  In the Repository, create a Folder named Settings, create a file <SolutionName>.json within it, copy the text from the Deployment Settings File

suparnabanerje_12-1674123826808.png

 

 

Create Build Pipeline

 

  1.             Create a new Pipeline with Classic Editor>Empty Job
  2.             Add the task Power Platform Tool Installer
  3.             Add a task Power Platform Pack Solution

suparnabanerje_13-1674123826818.png

 

Source Folder of Solution to Pack -Select Folder by clicking 3 dots

Solution Output File -<SolutionName>.zip

Type of Solution -Both

  iv.     Add a task -Copy Files

suparnabanerje_14-1674123826827.png

 

Source Folder -Settings

Contents -**

Target Folder - $(Build.ArtifactStagingDirectory)

 

  v.   Add a task Publish Artifact

 

suparnabanerje_15-1674123826835.png

 

 

Path to publish - $(Build.ArtifactStagingDirectory)

Artifact Name – drop

 

  vi.   Save and Queue the Build Pipeline

 

Create Release Pipeline

 

  1.             From Left navigation, click Releases >New Release Pipeline >Start with Empty Job
  2.             Add the Artifact created in the Build pipeline

suparnabanerje_16-1674123826845.png

 

Select your project and build pipeline

Source alias -drop

  1.             Under Stages>Stage 1>Click Job
  2.             Add the task Power Platform Tool installer
  3.             Add the task Power Platform Import Solution

 

suparnabanerje_17-1674123826855.png

 

      iv.   Service Connection – Select the service connection you created for Prod.

       v.   Solution Input File – Select clicking 3 dots, select the managed zip file for Prod

suparnabanerje_18-1674123826859.png

      vi.   Check Use Deployment Settings File and select the Deployment settings file by clicking 3 dots.

      vii.  For Prod, under Advanced, check Import Managed Solution

       viii.  Save the pipeline and create a Release

       ix.  Check the Solution has been deployed properly to Production

 

3b. Create Azure DevOps Pipelines with Managed Identity

 

    1. Create VMScaleSet and assign Managed Identity
    2. Create Self hosted Agent pool and point to the VMscale set
    3. Add the managed identity as App user into Power Platform source and destination environment.
    4. Create Service Connection with managed identity.
    5. 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 .

 

 

 

Comments

*This post is locked for comments

  • suparna-banerje Profile Picture suparna-banerje 36
    Posted 25 Jun 2024 at 16:42:08
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    @joecognizant Please check your Azure DevOps Project Settings if the creation of Classic Pipelines is disabled, you need to have it enabled to use the Classic editor

  • pradiptanayak1 Profile Picture pradiptanayak1 26
    Posted 24 Jun 2024 at 06:03:22
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    Why we need unpack and again pack solution ? I ready don't understand any Business or Technical use of it. We can export Managed  and then deploy to Target environment. 

  • joecognizant Profile Picture joecognizant 4
    Posted 20 Jun 2024 at 17:13:26
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    Hi @suparna-banerje

     

    I am not seeing the same steps to create a new pipeline - here is what I see:

    joecognizant_0-1718901624813.pngjoecognizant_1-1718901653430.pngjoecognizant_2-1718901683512.png

     

    Show More doesn't have anything relevant to Power Platform so I clicked Starter Pipeline (there was no option to select the classic editor or to start with an empty Job) and this is what I see:

     

    joecognizant_4-1718902019799.png

     

    After saving and running as is, I am in a detached HEAD state

    joecognizant_7-1718903239986.png

     

     

    joecognizant_6-1718902364546.png

     

    Here is my question:

     

    After following your steps to add the Tool installer, Exporting the solution, and Unpacking it, how do I commit?

     

    I tried this:

     

    taskCmdLine@2

      inputs:

        script: |

          echo commit all changes

          git config user.email Joe@blahblahblah.onmicrosoft.com

          git config user.name 'Automatic Build'

          git checkout -B main

          git add --all

          git commit -m 'code commit'

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

        workingDirectory'$(System.DefaultWorkingDirectory)'

     

    And I'm getting this:

     

    "Nothing to commit, working tree clean"

     

    Thoughts?

     

    Joe

     

  • Vish_s Profile Picture Vish_s
    Posted 11 Jun 2024 at 01:22:16
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    Make sure about your subscriptions.

  • nickf1 Profile Picture nickf1
    Posted 10 May 2024 at 14:02:37
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    pipeline runs without error, but does not seem to create any folders/files in my repo?  Any help appreciated. 

  • Ahmad Pirani Profile Picture Ahmad Pirani 32
    Posted 08 May 2024 at 15:24:11
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    @suparna-banerje,

     

    Any plans to provide detailed steps for Managed Identity just like you provided for Service Connection?

    I have created VM Set, created and assigned managed identity to the VM set, added the managed identity as app user to my Dynamics instance, created Power Platform service connection in Azure devops (it does not have much option than to just provide Dynamics org url).

    But when I create pipelines, the queue never runs. It sits in queued state forever.

  • suparna-banerje Profile Picture suparna-banerje 36
    Posted 03 May 2024 at 13:42:50
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    @vinayaknair2802 yes, it works for multi tenant deployment, provide your tenant id and app registration details while creating service connection

  • CU10051612-0 Profile Picture CU10051612-0
    Posted 23 Apr 2024 at 15:01:36
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    Hi @suparna-banerje ,

     

    Thanks for the article. Could you please let me know if this works for multi tenant deployment.

    I have a separate dev and QA tenant.

     

    Thanks

  • Anu262022 Profile Picture Anu262022 4
    Posted 17 Apr 2024 at 15:15:28
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    Hello Suparna,

     

    Thanks for reply, as you explained about manual/schedule the export pipeline, it would be greatful if you can share some article or any of your blog where you explained about the schedule/manual process.

     

    How schedule job will check that solution has some changes, because schedule job will always run and always update the pipeline. I think it it is not possible to manage this action thru schedule job, this can be done thru manual job.

     

    Thanks

    Avian

  • suparna-banerje Profile Picture suparna-banerje 36
    Posted 17 Apr 2024 at 14:28:38
    Detail Step-By-Step - Power Platform ALM with Azure DevOps

    @AvuanDecosta You can either manually trigger the Export pipeline after each change, or schedule the Export pipeline from the Triggers section, each export will bring the latest changes.