adaptive.run TECH BLOG

Cloud can be tricky sometimes. Find out what scenarios we've ran into that are worth being mentioned and explained.

Deploying Azure Bicep Using Azure
DevOps Pipelines

Level: 100
Publishing date: 14-Mar-2025
Author: Catalin Popa


Introduction

Azure Bicep simplifies the process of defining and deploying infrastructure-as-code. When combined with Azure DevOps Pipelines, Bicep deployments become automated and repeatable. In this guide, we will explore how to set up an Azure DevOps pipeline to deploy Azure Function Apps using Bicep.

1. What is Azure Bicep?

Azure Bicep is a domain-specific language (DSL) designed to replace JSON-based ARM templates. It provides a cleaner syntax, modularity, and improved readability while maintaining full ARM compatibility.

2. Bicep Sample Configuration

We will deploy Azure Function Apps using a Bicep file. The Function App will be connected to an Azure Storage Account for logging and execution purposes.

📂 Folder Structure:

Azure-Bicep-Deploy/
│── BicepFiles/
│ └── main.bicep
│── pipelines/
│ └── pipeline.yaml 

📌 Bicep File (BicepFiles/main.bicep)

param location string = resourceGroup().location
param functionAppName string = 'myFunctionApp'
param storageAccountName string = 'funcstorageapp'

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}

resource functionApp 'Microsoft.Web/sites@2022-09-01' = {
name: functionAppName
location: location
properties: {
serverFarmId: ''
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage'
value: storageAccount.properties.primaryEndpoints.blob
        }
      ]
    }
  }

This Bicep file:

✔ Creates an Azure Function App
✔ Deploys a supporting Storage Account
✔ Configures the function app settings dynamically

3. Configuring Azure DevOps Pipeline

Azure DevOps will be used to orchestrate the deployment. The pipeline will:
1. Build the Bicep file into an ARM template
2. Deploy the resources to Azure

📌 Pipeline File (pipelines/pipeline.yaml)

name: $(BuildDefinitionName)_$(date:yyyyMMdd)$(rev:.r)

trigger:
batch: true
branches:
include:
- main

pr: none

stages:
- stage: deployBicep
jobs:
- job: "BicepDeployment"
steps:

- task: PowerShell@2
displayName: 'Build Bicep File'
inputs:
targetType: 'inline'
script: |
az bicep build --file $(System.DefaultWorkingDirectory)/BicepFiles/main.bicep

- task: AzureCLI@2
displayName: 'Deploy Bicep Configuration'
inputs:
azureSubscription: 'my-azure-subscription'
scriptType: pscore
scriptLocation: inlineScript
addSpnToEnvironment: true
inlineScript: |
az group create --name function-rg --location eastus
az deployment group create --resource-group function-rg --template-file $(System.DefaultWorkingDirectory)/BicepFiles/main.json 


4. Running the Pipeline

Once the pipeline is pushed to the main branch, navigate to Azure DevOps Pipelines and trigger a manual run. The pipeline will:

1. Build the Bicep file
2. Deploy the infrastructure to Azure

Mobirise
azure.microsoft.com


Conclusion

This setup provides an automated way to deploy Azure Function Apps using Bicep and Azure DevOps Pipelines. Azure Bicep, combined with DevOps, enables efficient and repeatable infrastructure deployments. 🚀

Mobirise
adaptive.run

Transform your business.
Run adaptive.

Contact

Phone: +40 73 523 0005
Email: hello@adaptive.run

Mobirise Website Builder
Mobirise Website Builder

© Copyright  2019-2025 adaptive.run- All Rights Reserved