How the Power Platform Build and Release pipelines work

Introduction

Photo by Dan Gold on Unsplash

This post is part of a series of posts discussing my experiences with putting in place Dev Ops processes around the Power Platform.

If you have not read the introduction post, I would suggest starting there.

If you have read it then, that is great and thanks for taking time out of your busy schedule to read this.

As mentioned, there are two core pipelines, the build pipeline, and the release pipeline. This blog post will delve into how they work currently. I fully expect that they will change as I get feedback from the community.

I really look forward to that as I am sure they can be better! I have some ideas on some tweaks that need to be made.

Anyway, let’s get started.

The Build Pipeline

So, the Build Pipeline has a parameter block and a set of variables.

The parameter is used to decide whether the build should create a managed or unmanaged solution.

The parameters section

The variables are used to identify the solution (PowerPlatformSolutionName) that needs to be exported and the name of the environment (PowerPlatformEnvironmentName) that the solution needs to be exported from.

The final variable provides the major, minor, and revision numbers as the version prefix for the solution version. The build number is handled by a counter managed by Azure Dev Ops.

The first set of tasks install the Power Platform Build tools including the Power Apps CLI that are required to work with the Power Platform solutions.

Next, we resolve where the PAC tools are installed on the build agent and set the version number.

We then publish the customisations in the environment. This makes sure that we are using the latest version and if a developer has forgotten to publish something it will get picked up.

Then we set the solution version based on the build version. I like this as you can now tie the build / release process to the solution deployed to Power Platform!

Next, is exporting the solution. We do this twice! Once as an unmanaged solution and again as a managed solution. This means we have a copy of the solution held in source control in case something happens to the source Power Platform environment.

The next step extracts the solution settings, environment variables and connection references.

Next, we unpack the solution so that we can get the environment variables and blank them. This makes the solutions easier to port into the other environments. Also, if we want to apply settings as part of the release, we can do that!

Once we have extracted the environment variables and cleared them out, then we can pack the solution back up.

Finally, we take a copy of that solution settings file and use the Azure Dev Ops Publish Assets task. This associates all the files in the Artifacts Stage directory to this build.

These can be seen here.

Phew, let’s talk about the release pipeline!

Release Pipeline

The release Pipeline has been covered in a previous post a little but let’s discuss how it works.

These release or deployment pipelines need to deploy something. That something is referred to by the resources tag. In our example we are referring to the build Pipeline assets.

When you run the release Pipeline you can see here that the files are downloaded by the Download Artifacts task.

The release process will deploy to the various stages defined by this YAML script.

However, the main logic to deploy is held in another YAML file, as shown by the template parameter.

Let’s look at that YAML file!

This starts with a set of parameters that are used to deploy the solution.

The release is quite simple and to be honest there are some more things that we can do. For example, apply settings to the solution. However, I wanted to keep this part simple.

So, initial steps show the files that are part of the release (for debugging purposes).

Then we have a task which could be used to replace tokens. This might be used for example to set values in the settings file. (More on that in another post).

Next then we install the tooling using required for the Power Platform deployment.

The final task performs the actual deployment into the Power Platform solution into the environment using the PowerPlatform import solution task. This also applies the settings via the DeploymentSettingsFile parameter.

And to be honest that is it!

Conclusion

So, in this post we have covered how the pipelines work. I hope that it has been useful. I am sure you will have some improvements to suggest. Also, I bet there are some other ideas for what could do done here. If you do, I would love to hear them!

In the next post I will discuss some common issues that we have seen when deploying the solutions with these processes.

Setting up Build and Release Pipelines to deploy Power Platform Solutions.

Introduction

This post is part of a series of blog posts which cover my experiences and an approach to using the Power Platform Dev Ops tool chain to deploy Power Platform solutions with Azure Dev Ops.

If you are reading this and have not read the other articles, I recommend starting with the introduction post.

This post will discuss how to set up the build and release pipelines in Azure Dev Ops and discuss how they work.

Get the code

All the source code for the Pipelines can be found in my company’s GitHub Repository, https://github.com/ithinksharepoint/powerplatformdevops.

You will need to get the Github code and put this into your Azure Dev Ops Project Repository. At iThink 365 we create a folder called dev-ops in the root of the repository to hold these pipelines.

The dev-ops folder

Within the dev-ops folder are the following files:

  • i365-powerplatform-solution-build-pipeline.yml – this holds the build pipeline code.
  • i365-powerplatform-solution-release-pipeline.yml – this holds the release pipeline code.

The templates folder is used by the release pipeline to hold the deployment process. One of the beautiful things about YAML pipelines is that you can create templates, reuse, and link to them so that all deployments use the same approach.

The following setup will configure the following: 

  • Power Platform Build Pipeline 
  • Power Platform Release Pipeline 

The Build pipeline oversees publishing all customisations and exporting the solution out. It also unpacks the solution and associates the artifacts to a published asset which is attached to the build. 

One of the challenges that I faced with solutions is the management of environment variables. When you export solutions out from Power Apps or Power Automate with the user interface you need to clear out the environment variables before you export. 

This is a bit of an annoying step, the advantage of using the Power Platform Build tools is that the export solution step does this for you, so you don’t have to remember. So even if you implement the build pipeline it will leave you with a zip file which has your solution ready to go to be imported into another Power Platform environment! 

The release pipeline ensures that the solution built by the build pipeline is installed into the desired environment. 

Something to be aware of is the idea of managed and unmanaged solutions. A managed solution is setup so that you don’t change its configuration of it when imported into another environment. Unmanaged solutions are built to be changed for example they may be exported and put into your source control system for example. 

Setting up the Build and Release Pipelines

To setup the build and release pipelines do the following from within Azure Dev Ops.

Build Pipeline

  • Open Azure Dev Ops
  • Open the Project
  • Click on Pipelines, then Pipelines
  • Click New Pipeline
  • Choose Azure Repos Git
  • Select the repository that holds the pipeline YAML
  • Choose Existing Azure Pipelines YAML file
  • The select an existing YAML file task pane will appear and read all the YAML pipelines in the repository.
  • From the path drop-down select the pipeline i365-powerplatform-solution-build-pipeline.yml
  • Click Continue
  • The Review Your Pipeline screen will appear.
  • Click Run -> Save to create the pipeline.

The pipeline created will be given the name of your repository, so we need to change the name.

  • Click edit
  • Click the three dots and then choose Triggers
  • Now we can rename the build pipeline to something more suitable.
  • At iThink 365 we use the naming convention [Application Name] Build CI.
  • Change the name and then click on Save.

Next, setup the build variables so that the pipeline knows which solution to build and where that solution is held.

To setup the build variables:

  • Edit the Build Pipeline that we just created

  • Click Variables
  • Click New Variable
  • Create a variable called PowerPlatformEnvironmentName
  • The value should be the name of the Service Connection that you created for the Power Platform environment that holds the development version of your Power Platform solution. In our case that is Development and our value is Power Platform Dev Environment (dev.ithink365.co.uk).
  • Click Ok to add the variable.
  • Now add another variable called PowerPlatformSolutionName
  • The value should be the internal name for your solution. This can be found by looking at your solution and use the value from the name column.
Use the name of the solution rather the display name.
  • Last variable to add is called version.MajorMinor
  • This is the version number of the solution to use for the first three digits.
    • e.g. 1.0.1
  • Click Ok
  • Click Save to finish

Now your build pipeline is ready for use.

Let’s run the pipeline and make sure it is working.

  • If you do not have the pipeline open, then open and click Run Pipeline followed by Run

Wait for the pipeline to do its work, hopefully it will find your Power Platform environment and solution.

To view the pipeline, click on Job and you will see the pipeline output.

You will be asked to confirm that the pipeline can connect to the Power Platform environment when you run the build for the first time. So approve that request.

Wait for the job to complete, hopefully you will see a sea of green ticks as shown below.

If you do not then check the error message and use that to diagnose the issue. I will cover some of the common issues in a subsequent blog post. [TODO: add link to blog post]

Also, I will provide more details on how the build pipeline works in subsequent blog post.

Release Pipeline

Now with the Build pipeline working we need to release the code. So let’s setup the pipeline for releasing the solution into your environments.

So, following the same process for the Build Pipeline lets add a new pipeline.

  • Open Azure Dev Ops
  • Open the Project
  • Click on Pipelines, then Pipelines
  • Click New Pipeline
  • Choose Azure Repos Git
  • Select the repository that holds the pipeline YAML
  • Choose Existing Azure Pipelines YAML file
  • The select an existing YAML file task pane will appear and read all the YAML pipelines in the repository.
  • From the path drop-down select the pipeline i365-powerplatform-solution-release-pipeline.yml
  • Click Continue

Next, we need to add a variable called PowerPlatformSolutionName. This is slightly different as it is the name of the solution zip file. So, use the value that you used for the build pipeline but add Solution.zip to the end.

For example, our solution was called iThinkHR and its zip file name will become iThinkHRSolution.zip.

  • Click OK
  • Click Save
  • Click Save once again to create the pipeline.

We have created our pipeline, of course we need to give it a good name.

  • Click edit
  • Click the three dots and then choose Triggers
  • Now we can rename the build pipeline to something more suitable.
  • At iThink 365 we use the naming convention [Application Name] Release.
  • Change the name and then click on Save.

Now we need to talk about the release pipeline a little as unlike the Build Pipeline it is more difficult to have a standard Release pipeline that you can use for all your Power Platform solutions. This is because each solution will be deployed to different environments. Also, we need to reference the build pipeline that is creating the assets that we are going to deploy. We need to reference that pipeline directly in the YAML. I have not found a way to get around that yet. So let us go over the pipeline and explain some of the YAML.

Firstly, the resources statement this is the section of YAML shown below.

The resources statement

In deployment/release pipelines you need to specify the assets that you are going to release. This is done by the resources section as you can see this reference’s the build pipeline which we are giving an alias of api. The source is the name of the build pipeline that creates the resources. Finally, the trigger statement is set to none. Which means that when the build pipeline completes this release process will not trigger. However, we can change that if we wish to.

If you want the release process to trigger on the completion of a build, you can do that. I will explain how in our hint and tips blog post.

So, make sure that the source value is the same name as the build pipeline that we created earlier.

Next let’s talk about the stage section along with the strategy. This is where the release pipelines are a bit different to build pipelines as there are different deployment strategies that you can use. We are not really worried about that for our type of deployment but if you wish to read more then check out this post.

For us we are going to use the runOnce deployment strategy.

Let’s pull out some key sections. Firstly, for the stage we use the name of the environment that we are going to deploy to. In this example that is Production. The keyword dependsOn is important as this is how to order the deployment process so that environments are deployed to in a particular order. In this example Production has no dependencies. That cannot be right, lets show another example with some dependencies.

This dependsOn has Test which means that another stage called Test has to complete before the Production deployment occurs. Also, we have a condition in this example which will check to ensure that all the steps have completed successfully for this stage to execute. There are some additional things that we can do to control the release process which will be discussed later.

Note the template section, along with some parameters. The template uses parameters and we need to provide those via the parameters section so it can execute correctly.

The PowerPlatformTargetEnvironmentName should be set to reference the name of the service connection associated to the environment that we are going to use to deploy the solution to.

Finally, the PowerPlatformSolutionSettingsFileName is a JSON file which is created by the build pipeline and extracts all the environment variables from. But let’s ignore that for now and discuss later.

So, take the example pipeline and remove the stages that you do not need. Make sure you update the PowerPlatformEnvironmentName to the name of your service connection for the environment.

Run the pipeline when you are ready. This normally takes a couple of goes to get right.

When first running the pipeline use the following tip to check if your pipeline is ok.

  • Click on Run
  • Click on Stages to run

If you see an error displayed then examine the error message and fix the pipeline code.

  • Choose the Test environment
  • Click Use selected stages
  • Click Run

Click on the stage to watch it run.

If the pipeline has not run against this environment, you may be asked to authorise it to access the environment.

All being well your release pipeline will have completed successfully and you will now be able to see the Power Platform Solution in your Test Environment.
Screenshot showing the successful deployment into the Test environment.

Conclusion

Now, we have taken you through how to setup build and release pipelines. The result is that we have a way to deploy our solutions to our different Power Platform environments.

In our next post let’s talk about how these the pipelines work before we discuss some different scenarios and options that we can setup to give us control of our deployments.

Photo by Drew Sal on Unsplash