What is Bicep - Bicep is a transpiler that converts new Bicep Language to ARM templates. We will look into Bicep language in a second. Before that, let’s take a step back and understand why this was introduced.
If you have been working with JSON ARM templates, you would have noticed how cumbersome it can be when it is large. There are problems with current JSON ARM templates
Microsoft wants to simplify this and ensure only one path to deploy on Azure. But, Azure Resource Manager is huge and it has APIs for every service in Azure that works with Json ARM template. Its a huge work to change this. So, instead of making changes to Azure Resource Manager, Microsoft has introduced a new language called Bicep and built a transpiler that converts bicep language to ARM templates.
The bicep is a transpiler. A transpiler that converts the new Bicep language into ARM Templates.
Follow the instructions below.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/installvar storageAccountName = 'strgaazfunction' resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = { name: storageAccountName location: location sku: { name:'Standard_LRS' } kind: 'Storage' }
It is
We will deploy a simple Azure function bicep template using Azure devops pipeline.
Download the bicep template for azure functions here - git repo
For a detailed walk-through, refer to the YouTube video shared above
# Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml trigger: none pool: vmImage: ubuntu-latest stages: - stage: Lint jobs: - job: LintCode displayName: Lint Code steps: - script: | az bicep build --file function-consumption-plan/storage.bicep name: LintBicepCode displayName: Run Bicep Linter - stage: Validate jobs: - job: ValidateBicepCode displayName: Validate Bicep Code steps: - task: AzureCLI@2 name: RunPreflightValidation displayName: Run Preflight Validation inputs: azureSubscription: 'Subscription-PAYG' scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az deployment group validate --resource-group $(resourceGroupName) \ -f function-consumption-plan/storage.bicep \ --parameters function-consumption-plan/storage.parameters.json - stage: Deploy jobs: - job: Deploy steps: - task: AzureCLI@2 name: Deploy displayName: Deploy to Azure inputs: azureSubscription: 'Subscription-PAYG' scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az deployment group create --name $(Build.BuildNumber) --resource-group $(resourceGroupName) \ -f function-consumption-plan/storage.bicep \ --parameters function-consumption-plan/storage.parameters.json
Legal Stuff