Quickstart: Integrate Bicep with Azure Pipelines

This quickstart shows you how to integrate Bicep files with Azure Pipelines for continuous integration and continuous deployment (CI/CD).

It provides a short introduction to the pipeline task you need for deploying a Bicep file. If you want more detailed steps on setting up the pipeline and project, see Deploy Azure resources by using Bicep and Azure Pipelines on Microsoft Learn.


If you don't have an Azure subscription, create a free account before you begin.

You need an Azure DevOps organization. If you don't have one, create one for free. If your team already has an Azure DevOps organization, make sure you're an administrator of the Azure DevOps project that you want to use.

You need to have configured a service connection to your Azure subscription. The tasks in the pipeline execute under the identity of the service principal. For steps to create the connection, see Create a DevOps project.

You need a Bicep file that defines the infrastructure for your project. This file is in a repository.

Create pipeline

  1. From your Azure DevOps organization, select Pipelines and New pipeline.

    Add new pipeline

  2. Specify where your code is stored.

    Select code source

  3. Select the repository that has the code for your project.

    Select repository

  4. Select Starter pipeline for the type of pipeline to create.

    Select pipeline

Azure CLI task

Replace your starter pipeline with the following YAML. It creates a resource group and deploys a Bicep file by using an Azure CLI task:

- master

name: Deploy Bicep files

  vmImageName: 'ubuntu-latest'

  azureServiceConnection: '<your-connection-name>'
  resourceGroupName: 'exampleRG'
  location: '<your-resource-group-location>'
  templateFile: 'main.bicep'
  vmImage: $(vmImageName)

- task: AzureCLI@2
    azureSubscription: $(azureServiceConnection)
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az --version
      az group create --name $(resourceGroupName) --location $(location)
      az deployment group create --resource-group $(resourceGroupName) --template-file $(templateFile)

The Azure CLI task takes the following inputs:

  • azureSubscription, provide the name of the service connection that you created. See Prerequisites.
  • scriptType, use bash.
  • scriptLocation, use inlineScript, or scriptPath. If you specify scriptPath, you'll also need to specify a scriptPath parameter.
  • inlineScript, specify your script lines. The script provided in the sample deploys a Bicep file called main.bicep.

Select Save. The build pipeline automatically runs. Go back to the summary for your build pipeline, and watch the status.

Clean up resources

When the Azure resources are no longer needed, use the Azure CLI or Azure PowerShell to delete the quickstart resource group.

az group delete --name exampleRG

Next steps