Deploy Bicep Templates With Azure DevOps Pipeline

This Microsoft Azure DevOps and Bicep will show you to deploy a Bicep template to Microsoft Azure using a pipeline.

Azure DevOps pipelines allow us to automate the creation and management of resources in Microsoft Azure using source code.

When creating resources in Azure, we can use Bicep, our templates and a pipeline to deploy them and create resources.

In my case, I have a Bicep template that creates a Storage account on Microsoft Azure.

Use Bicep With Azure DevOps Pipelines

To deploy my Bicep template, I will start by creating a new YAML pipeline from the Azure DevOps portal and connect the pipeline to my source code.

Code

Below, I’m using the following task to deploy my Bicep template. Notice that this is the same task we use to deploy an ARM template. To only difference is that I’m not using a parameters file.

The csmFile option points to the Bicep template (2.1.storage_account. Bicep)

steps:
- task: [email protected]
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: 'ADD-DETAILS'
    subscriptionId: 'ADD-DETAILS'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'bicaplab'
    location: 'ADD-DETAILS'
    templateLocation: 'Linked artifact'
    csmFile: '2.1.storage_account.bicep'
    deploymentMode: 'Incremental'

Note: You can use the ARM template deployment task in the Tasks Assistant (see below).

I will run the pipeline to create the storage account using the Bicep template (see below).

The storage account will appear in the Azure portal when the deployment is completed.

Processing…
Success! You're on the list.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.