Azure Bicep makes it easy to write Infrastructure as Code (IaC) for deploying Azure resources. When used with Azure Pipelines, it automates deployments efficiently. This article explains how to create a storage account in Azure using Bicep and Azure Pipelines step by step.

Step 1. Create a Bicep Template in the Azure Portal

Azure lets you easily create Bicep templates directly in the portal. Here's how,

Fill in details like,

Export the Bicep Template

Step 2. Set Up Your Azure Repo

Push the Bicep File to the Repository.

Step 3. Create an Azure Pipeline

Set Up the Pipeline.

Write the Pipeline YAML: Below is a sample pipeline YAML to deploy your Bicep template.

trigger:
  - main

pool:
  vmImage: 'windows-latest'

stages:
  - stage: DeployStorageAccount
    displayName: Deploy Storage Account
    jobs:
      - job: Deploy
        displayName: Deploy Bicep Template
        steps:
          - task: AzureCLI@2
            inputs:
              azureSubscription: '<Subscription-Name>'
              scriptType: 'ps'
              scriptLocation: 'inlineScript'
              inlineScript: |
                az deployment group create `
                  --resource-group "<Resource-Group-Name>" `
                  --template-file "bicep-templates/template.bicep"

Replace Placeholders.

Save and Run

Save the pipeline and click Run Pipeline to trigger it.

Pipeline Run Window View.

Pipeline Run Window

Storage Account Created in Azure Portal.

Storage Account Created