Looking to move from writing your Azure Resource Manager (ARM) templates in JSON to Bicep? The good news is Microsoft have provided some tooling to make it relatively straightforward too migrate.
1. Run the Bicep command line interface (CLI)
Once setup, you can run the
decompile command for the Bicep CLI that will take your JSON ARM templates and convert them into rudimentary Bicep files. Run this command by navigating to the location of your JSON files within your command line and calling:
az bicep decompile --file your-arm-template-file-name.json
This will create a Bicep file for you in the same directory. Note that if you already have a Bicep file of the same name within the same directory, you’ll need to add
—force to the end of the command.
2. Review & update Bicep file
While the file created in step 1 is a good start, you may encounter issues where the decompiler is unable to transfer complex resources or logic across from your JSON files to the Bicep file. Normally this will be called out with warnings or errors in the command line after you run the
So the first thing you should do after running
decompile is compare your JSON file against the Bicep file to ensure all your resources and configurations have been carried across.
Then you’ll want to refine your Bicep file, and adjust things like resource naming and address issues raised by the Bicep linter. Within VS Code (and with the Bicep extension installed) you should see these appear as yellow or red warnings.
Lastly you’ll also want to look at Microsoft’s published best practices guide for Bicep to ensure you’re aligned with them. In particular look for things like template functions that may no longer be required with Bicep, such
3. Update CI/CD pipeline
Depending on your setup, you’ll also likely need to update your CI/CD pipeline to use your new Bicep files instead of the ARM JSON templates. In some cases, you may still wish to compile your Bicep files into ARM templates by running the following command:
az bicep build --file your-bicep-file-name-here.bicep
Note that in most cases this is unnecessary as most Azure CLI commands will run this for you automatically.