Deploying Azure resources in an automatic, consistent and predictable way can be done using several techniques and tooling. Think of ARM templates, Azure DevOps pipelines tasks, the Azure .NET SDK or using some 3rd-party tooling like Ansible, Pulumi or Terraform for example.

Recently Microsoft added Azure Bicep to this list, a new and free way for deploying resources on Azure.

Characteristics

Azure Bicep is a new Domain Specific Language designed by Microsoft for creating Azure Resources. It uses a declarative syntax with desired state configuration. There is tooling support for Bicep in Visual Studio Code which brings you snippets, syntax checking and code completion. Bicep deployments are idempotent by default and all Azure resource types and Azure API versions are supported. Azure Bicep is free and ready to be used in production environments and backed by Microsoft support.

Getting started

I would recommend installing the Azure Bicep extension for Visal Studio Code as a starting point. The Extension can be found in Bicep extension for Visual Studio Code

Example .bicep file

Resources are declared in a .bicep file, like:

@minLength(3)
@maxLength(24)
@description('Provide a name for the storage account. Use only lower case letters and numbers. The name must be unique across Azure.')
param storageName string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
  name: 'bicepvnet'
  location: resourceGroup().location
  properties: {
    addressSpace: {
      addressPrefixes: [
        '10.0.0.0/16'
      ]
    }
    subnets: [
      {
        name: 'Subnet-1'
        properties: {
          addressPrefix: '10.0.0.0/24'
        }
      }
      {
        name: 'Subnet-2'
        properties: {
          addressPrefix: '10.0.1.0/24'
        }
      }
    ]
  }
}

resource bicepStorage 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: storageName
  location: 'westeurope'
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
}

This .bicep file contains definitions to create a Virtual Network and a storage account in Microsoft Azure. It looks like a better readable ARM template but it has some nice additional features as well, e.g. take a look at the decorator validators for the storageName parameter.

Deployment

To deploy the .bicep file we can use the Powershell or the Azure CLI quite similar to an ARM deployment:

az group create --name bicepDemo --location westeurope

az deployment group create --resource-group bicepDemo --template-file main.bicep --parameters storageName=bicepdemo

Additional the Azure Bicep extension for Visal Studio Code can make a Visualization of the deployed resources and there is even an option to decompile a traditional ARM .json template to a .bicep template: az bicep decompile --file template.json

For more info please check out the Azure Bicep Quickstart and the official Azure Bicep documentation