Post

Deploying BICEP using Azure DevOps Pipeline

Deploying BICEP using Azure DevOps Pipeline

Recently I was more looking into bicep side of things in Azure. And I wanted to deploy the bicep templates using azure DevOps. 😊

I came up with the following workflow to deploy the templates to Azure.

I believe this approach is quite good because

  1. Using the standard approach of build and deploy
  2. I will get to see if there are any errors in bicep files during the build
  3. Saving to artifacts will give the opportunity to go back instantly

Azure DevOps Repository

I will be using a native Azure DevOps repository to hold the bicep code. Feel free to use GitHub also if you prefer.

I have created a new project inside my DevOps organization and uploaded the Bicep code

Build Pipeline

Idea behind this build pipeline is the represent the build stage by compiling the bicep code in to Arm template and will be saving json file inside the artefacts

Following are the steps

[![](images/image-23.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-23.png)
**_Select your azure repository_**
[![](images/image-24.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-24.png)
**_Select Starter Pipeline_**
[![](images/image-25.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-25.png)
**_Remove the default code_**
[![](images/image-26.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-26.png)
**_Enter the new Code as above_**

Note:Β  Code is saved in my public GitHub. Head out there are and grab it

My yml file does have 2 tasks

Task 1 - Compiling the bicep template into an arm template using Az PowerShell modules

Task 2 – Saving the converted ARM template into artifacts.

Once all done hit save and exit or you can run the pipeline to make sure everything works. Now let’s move to the deploy component

Release Pipeline

In the release pipeline we will be using the successful built arm template in the above-mentioned phase to deploy it to the Azure. We will be selecting the ARM template from the Artifacts location and will be adding the ARM template deployment job.

Let look at how we can achieve this

[![](images/image-28.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-28.png)
**_Create a new release pipeline_**
[![](images/image-29.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-29.png)
**_Select an Empty Job_**
[![](images/image-30.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-30.png)
_**Add new**_ **_Artefacts and from the drop down select the build pipeline details_**
[![](images/image-31.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-31.png)
**_Select Jobs_**
[![](images/image-32.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-32.png)
**_Add a new job and select ARM template deployment_**
[![](images/image-33.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-33.png)
**_Select the selected job and fill the required details for you AZ subscription. Filled form is below._**
[![](images/image-34.png)](https://hungryboysl.wordpress.com/wp-content/uploads/2021/10/image-34.png)
_**Note: When selecting the template section in the form you can hit the 3 dots in**_ **_In front of the text box and select our artefacts as below_**

Note: When selecting the template section in the form you can hit the 3 dots in Infront of the text box and select our artefacts as below

Once done you are done with the configurations. Simply you are run the build pipeline and then the release pipeline. Based on the configurations you select your deployment will get completed.

If you have any questions, please comment down below. Will get back to you as soon as possible

This post is licensed under CC BY 4.0 by the author.