Create an Azure DevOps Release Pipeline for ARM Template Deployment

Azure DevOps provides pipelines for both Continuous Integration (CI) aka “Build” and Continuous Delivery (CD) aka “Release”.

In this post I will create a Release Pipeline to deploy an ARM Template using an Artifact produced in a Build Pipeline we created previously here: Create an Azure DevOps Build Pipeline (Classic) for ARM Template Deployment.

Artifacts

The end result of our Build pipeline, was an Artifact containing our validated ARM Template.

This Artifact can be viewed by clicking on the “1 published” link on the Build pipeline run summary page.

This will take you to the Artifact within a drop folder containing our azuredeploy.json and azuredeploy.parameters.json files which create a storage account.

Release Pipeline

We are now going to create a Release pipeline to perform an ARM template deployment and create our storage account.

Navigate to Pipelines –> Releases.

Click on “+ New” and select “+ New release pipeline”.

Choose “Empty pipeline” when provided with the template options below.

Now we have an empty pipeline, we first need to add our Artifact.

Click on “Add an artifact”.

Select the following:

  • Source type: Build
  • Project: (your project name)
  • Source: (your build pipeline name)
  • Default version: Latest (or latest from a branch such as main/master)

Click Add to add the Artifact to the pipeline.

Click on the lightning icon on the Artifact. Here you can configure triggers so that the release pipeline runs after a build pipeline us run. For now we will leave this disabled and trigger the release pipeline manually.

Stages

Click on the lightning icon on the Stage 1. Here you can configure the trigger to run as soon as a new release is created. We will ensure this is set to “After release”.

Now we need to configure our stage.

Click on 1 job, 0 task.

Give the stage an appropriate name, such as “Create Storage Account”.

Click on “Agent Job”, review the settings and change Agent specification to “windows-2019” or your desired ADO agent OS.

All other settings can be left for now, but here you can choose to use self-hosted agents for this stage if you have them and parallel job execution.

Tasks

Next we add a Task to the Job.

Click the “+” and add “ARM Template deployment”.

Enter a name such as “ARM Template deployment: Storage Account”.

Configure the following settings as required:

  • Deployment Scope: Resource Group
  • Azure Resource Manager connection: <this should have been setup when the project was created>
  • Subscription: <your subscription to deploy to>
  • Action: Create or update resource group
  • Resource Group: e.g. RG-UKS-T-ARM-LAB-01
  • Location: UK South
  • Template Location: Linked Artifact
  • Template: $(System.DefaultWorkingDirectory)/_Build Pipeline ARM Template Storage Account/drop/azuredeploy.json
  • Template Parameters: $(System.DefaultWorkingDirectory)/_Build Pipeline ARM Template Storage Account/drop/azuredeploy.parameters.json
  • Deployment Mode: Incremental

Give your pipeline a name, such as “Release Pipeline Storage Account”.

Click Save.

Release

Click “Create Release”.

Enter a release description if desired and click “Create”.

The release is created (in my case its the second release) and it will begin to run automatically because we set the stage to trigger “after release” earlier in the pipeline configuration.

Click on “Release-1” or the number of your release and view the pipeline progress.

It will first queue for an agent to run the pipeline job.

The agent will then run the tasks, such as downloading the Artifact and the ARM Template deployment.

This will only take a few seconds for our storage account creation to complete, at which point it will show as “Succeeded”.

Looking back at the releases for the pipeline, it also confirms from this view that the “Create Storage Account” Stage in the release was successful.

Finally we verify the Storage Account was created in our Resource Group.

To summarise what we have accomplished…
We created a release pipeline which takes an Artifact from a build pipeline. It then uses the ARM Template and parameter file within the Artifact to deploy a storage account.
Whenever a new release is created when changing or adding stages or job tasks within the release pipeline, a new run will automatically trigger after release.