Last fall, I posted about Project Bicep. At the time it was a very early concept to replace standard ARM templates using JSON. Since the syntax is not JSON, the syntax is much easier to validate with Intellisense and simplifies the syntax.
Exporting Resources in Azure
You may not be sure where to get started with Bicep. You may have visited the Azure Portal, clicked on a resource, and then on
Export template in the Automation section. However, the template is in the original JSON format and not Bicep. That’s ok. Let’s download one of our resources to get started using Bicep for Infrastructure as Code. By default, parameters will be included. We’ll be using the
template.json file in the download.
template.json file to a folder that you can easily navigate to in Powershell.
To install Bicep, first make sure you have the latest version of the Azure CLI installed. As of this post, the latest version was 2.29.0. You can update the Azure CLI by following the instructions available here. Next, install Bicep using the Azure CLI command
az bicep install which is available in version 2.20.0 of the CLI and later:
1 az bicep install
Once it’s successfully installed, you should receive the appropriate message:
It’s also good practice to upgrade bicep, which is updated out of band. You can do this by running:
1 az bicep upgrade
Convert the ARM JSON to Bicep
The final step is to decompile the ARM JSON to Bicep. Luckily, the bicep CLI has a tool that, as advertised, is a “best-effort process” to decompile. To run this process, run the following command:
1 az bicep decompile --file template.json
After you execute, as long as the ARM JSON was properly formatted, you should have a new file with the same root name as the ARM JSON file, but with a
.bicep extension. As mentioned in my previous post about Bicep, one of the benefits is a simplified representation of the infrastructure as code. In my case, I was able to condense the file from 7.86 KB to 4.42 KB.