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
- Using the standard approach of build and deploy
- I will get to see if there are any errors in bicep files during the build
- 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
The idea behind this build pipeline is the represent the build stage by compiling the bicep code into Arm template and will be saving JSON file inside the artifacts
Following are the steps
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 successfully built arm template in the above-mentioned phase to deploy it to Azure. We will be selecting the ARM template from the Artifacts location and will be adding the ARM template deployment job.
Let's look at how we can achieve this
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
Hi.
ReplyDeleteYou dont need to convert BICEP to ARM json. The Azure resource manager knows about BICEP file. So you can give the BICEP file directly to deployment. The ARM converts BICEP to JSON automatically.
From a CI perspective - i would just do a bicep build - just to make sure that i dont have compilation errors. I would package all the bicep file required in CI step.
In CD you will pull down the package and call az deploy with bicep file passed as input.
Just thought of sharing the info.
Hey Lohith,
ReplyDeleteTotally agree with you, There are many different way to do it. What you have explained is also a very good method of deploying. Thanks for sharing :)
[…] Deploying BICEP using Azure DevOps PipelineDanidu Weerasinghe provides his experience deploying a Bicep template via build and deploy Azure DevOps pipelines. […]
ReplyDelete[…] Deploying BICEP using Azure DevOps PipelineDanidu Weerasinghe provides his experience deploying a Bicep template via build and deploy Azure DevOps pipelines. […]
ReplyDelete[…] Deploying BICEP using Azure DevOps Pipeline Danidu Weerasinghe provides his experience deploying a Bicep template via build and deploy Azure DevOps pipelines. […]
ReplyDelete[…] Note – I have already discussed how to deploy bicep using Azure DevOps in of my earlier posts […]
ReplyDelete