Azure Biceps — Next Generation of ARM Templates
Are you a fan of Infrastructure as Code and using ARM templates for setting up new environments in Azure?
If yes, you might agree that creating ARM templates is hard. They have a high learning curve and quickly become large and complex, especially with the deployment of many Azure Resources. Deployment with linked templates is not easy and the more we use it, the more we miss simple programming language possibilities like object modelling. Creating and reading ARM templates needs a lot of practice. Most of the time not everybody on the team is able to do this.
Open source community has recently introduced the next generation of ARM templates called Project Biceps.
What is Bicep?
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-uses.
As developers, we can easily correlate to the syntax of this new language, which makes it easy to learn and code complex infrastructure.
How it works?
Bicep code is transpiled to standard ARM Template JSON files, which effectively treats the ARM Template as an Intermediate Language (IL).
Software Pre-requisite
1. Bicep CLI (required) — Compiles Bicep files into ARM templates. Cross-platform
i) Install and manage via Azure CLI (easiest)
If you already have the latest version of Az CLI installed (v2.20.0 or later), the Bicep CLI will automatically be installed when a command that depends on it is executed.
You can also manually install the CLI using the built-in commands:
az bicep install
ii) Windows Installer
· Download the latest Windows installer.
· Run the downloaded executable. The installer does not require administrative privileges.
· Step through the installation wizard.
· After the installation, Bicep CLI will be added to your user PATH. If you have any command shell windows open (cmd
, PowerShell
, or similar), you will need to close and reopen them for the PATH change to take effect.
2. Install the Bicep VS Code extension (optional) — Authoring support, intellisense, validation.
With intellisense support it becomes easy to know supported properties for each resource and also identifying errors while working on it
Working Illustration
· Create a new virtual machine with disk size 100GB in West Europe region
· Create a Blob Storage with enforced HTTPS Only traffic
Bicep Build
Now when we have our bicep code ready, we need to build it using ‘bicep build’ command and as the build output we get an ARM template generated, which can be used for actual deployment.
bicep build “path/to/file.bicep”
Bicep Decompile
If you have an existing ARM Template or set of resources that you would like to convert to .bicep format, then Bicep CLI provides the ability to decompile any existing ARM Template to a .bicep file, using the decompile command:
bicep decompile "path/to/file.json"
Bicep Playground
If you want to have a quick look of its abilities without installing it locally, then access the Bicep Playground here.