The az bicep cli — almost good

A review on the az bicep cli. What it does, how to use it and what can be done better.

DataFairy
3 min readAug 8, 2023

What is Azure Bicep?

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. I have written a review of Bicep some time ago. It might be outdated to some extent but the main concepts are still valid.

What is the az bicep cli?

The az bicep cli is an extension of the az cli, which is a Microsoft Azure command line tool. It’s more readable than powershell if you need to do something quickly and don’t have an AI tool yet to assist you such as CodeX.

The az cli makes it possible to deploy resources to Azure from the command line without having to write your own configuration files.

The az bicep cli is an extension of the az cli. It should be used with .bicep files. These are configuration files to deploy resources to Azure with Bicep.

How to use it?

The az bicep cli offers a list of commands to help you work with Azure Bicep.

Some of the commands worth mentioning are:

  • az bicep format (formats your bicep files)
  • az bicep build (validates your bicep files)
  • az bicep decompile (converts ARM .json files to .bicep files)

The good.

  • The az bicep cli is easy to install and to upgrade. Compared to Terraform where I have to reinstall the cli manually I prefer this version.
  • There are a lot of options to the az bicep cli that will be useful when working with Bicep files.
  • It’s easy to transform the old ARM (Azure Resource Manager) format to the new Bicep format and with a script it is possible transform an entire directory.
  • Authentication to Azure is still done with az login. The extension integrates well with the current framework.
  • It’s now possible to easily validate Bicep files and this can be integrated in a CI/CD pipeline.

The not yet good.

  • The naming of the validate command bugs me seriously. It’s not clear what build means and can be confusing to use. Once you know it’s validation it becomes one of the important command.
  • It’s not really clear to which standards az bicep format is formatting the files. This becomes clear when you have multi-line spaces and the command moves the code until it has a 2 line difference to the previous code block. But when the minimum space (2 lines) isn’t there, format won’t do a thing even though I would expect it to move the codeblock .
  • The parameters file has been changed from a .json file to a .bicepparam file. az bicep generate-params still outputs a .json file. There is no option to specify it to output a .bicepparam file.
  • az bicep generate-params outputs mostly empty parameter files. It’s not a very useful command yet.

Why I like it.

The ease of installation is the main selling point for me. I can just run az bicep upgrade and get the latest version.

Another useful command is validate or az bicep build. To be able to validate the files in a pipeline with just one command is really an important feature.

Finally, when looking at the available commands and keeping in mind that they will work properly one day, I do think there is a lot of potential in this extension.

How to make it better

I would like to have the option to look at a deployment plan before I sign off on the latest version of my bicep and parameters files (integrate the az what-if option?). This could also be integrated in the az bicep cli and would work in a DevOps pipeline.

If you found this article useful, please follow me.

--

--

DataFairy

Senior Data Engineer, Azure Warrior, PhD in Theoretical Physics, The Netherlands. I write about Data Engineering, Machine Learning and DevOps on Azure.