Deploying BICEP using Azure DevOps Pipeline

Deploying BICEP using Azure DevOps Pipeline, this is going to be a quite interesting topic but before deployments what is bicep ? Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources.

BICEP is a quite fascinating territory to conquer. Why because of some unique things that makes your life easy as a devops engineer. Some of the things would be

  1. It simplifies complex gigantic arm templates
  2. We can use modules
  3. No state file to manage
  4. Etc…

Because of above and many more reasons recently I was more looking into new bicep DSL for Azure. After a bit of reading and investigation, I wanted to deploy the bicep templates using azure DevOps. 😊

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

Deploying BICEP using Azure DevOps Pipeline

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 artefacts 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

Select your azure repository

Select Starter Pipeline

Remove the default code

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

Create a new release pipeline

Select an Empty Job

Add new Artifact and from the drop down select the build pipeline details

Select Jobs

Add a new job and select ARM template deployment

Select the selected job and fill the required details for you AZ subscription. Filled form is 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.

Having said that, there are other methods also to deploy bicep using a DevOps pipeline.

  1. Directly deploy Bicep from the build pipeline without the release pipe.
  2. Build the bicep to json file in the build stage and rather than using the arm template (output of the previous pipe) use az powershell module to deploy the bicep template in the release.
  3. Etc….

Even if we deploy the bicep file Microsoft will convert out bicep to arm and deploy it to the environment.

Our devops done right solution we help you to get established framework to adopt a DevOps culture in your organisation. And help you to choose what’s best for you

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

[mailpoet_form id="1"]

Other Recent Blogs

Level 9, 360 Collins Street, 
Melbourne VIC 3000

Level 2, 24 Campbell St,
Sydney NSW 2000

200 Adelaide St,
Brisbane QLD 4000

191 St Georges Terrace
Perth WA 6000

Level 10, 41 Shortland Street

Part of

Arinco trades as Arinco (VIC) Pty Ltd and Arinco (NSW) Pty Ltd. © 2023 All Rights Reserved Arinco™ | Privacy Policy
Arinco acknowledges the Traditional Owners of the land on which our offices are situated, and pay our respects to their Elders past, present and emerging.

Get started on the right path to cloud success today. Our Crew are standing by to answer your questions and get you up and running.