Move over ARM, Bicep is here.
--
I’ve never really taken to ARM templates on Azure, they feel fiddly and don’t read overly well. Even an ARM template generated from the Azure Portal is pretty horrific and in my opinion, has been a major negative for Azure for several years. For those reasons, my go-to for Azure Infrastructure as Code has always been Terraform, and although I still prefer the YAML defined CloudFormation templates on AWS, Terraform’s HCL is a pretty close second contender.
So what is Bicep? Microsoft claims:
Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. It aims to drastically simplify the authoring experience with a cleaner syntax, improved type safety, and better support for modularity and code re-use.
From my initial experience, and even though Bicep is still in preview, it is certainly everything they claim it to be. Pair this with the VSCode plugin and it was extremely easy to get started.
Everything you could do in ARM was available in Bicep on day one, which is rare for a tool in preview, but makes sense given Bicep is an abstraction that sits on top of ARM. You can even cross-compile your templates between the two, which is a bonus if you’ve already invested in ARM and are looking to switch.
Getting Started
The setup for Bicep is pretty straight forward, install (or upgrade) the Azure CLI, to at least 2.20, and add the VSCode extension (not required, but everyone loves code-hints).
Next, we’ll create a file called main.bicep which contains code for a simple storage account with set the kind to blob storage (though it could be any kind):
Then we’ll create a resource group to deploy into:
az group create --resource-group my-rg --location australiasoutheast