Intro
Export template in the Azure Portal is a useful tool to lean on when you need to understand a resources properties, syntaxes, and structure.
We’ve all been there, deploying some Bicep or ARM, but it’s failing on some SKU or it doesn’t like some syntax. Whilst the MS Docs are usually fantastic at showing examples, detailing SKUs, properties, and everything else. Sometimes there are instances where they are unclear or simply missing valid examples.
As a pre-req you’ll need to deploy the resource in the GUI or have an existing resource to compare with.
Where is the Export Template option?
Located in the Azure Portal, browse to any resource and you’ll find it under Automation > Export template:
Comparing work examples to your Bicep code
Let’s see an example of how this can help out.
Once you open the Export template option, you will be presented with the ARM template for the resource. From here, you can now locate the property you want to review and check. For example:
Working example – Virtual Machine image reference properties
GUI showing the virtual machines image reference properties:
Example Bicep Code error comparison
Now you know the exact image reference properties, you can double check our code to make sure it’s matching what we require to understand why it’s failing:
We can see the SKU in the code is slightly incorrect and missing the ‘-gensecond‘ at the end.
Syntax and formatting help
Whilst the above is useful to know if all other avenues fail, there is another useful reason the Export template option can be leveraged.
Bicep is still fairly new to the scene and not hugely adopted like Terraform. You will likely find some docs or issues with some newer resources, bugs as it’s still being quite aggressively developed by the awesome Bicep team. The Export template can help bridge the gap between some of the unknowns.
The formatting the template can help identify some of these unknowns. Understanding how Logic App connectors and what each connector syntax & format will look like as an example.
Converting ARM templates to Bicep
For me, this is where this can be really helpful. Utilising the decompiling from JSON to Bicep in the Bicep CLI you can download the ARM template from the portal and run the decompile command to convert it into Bicep.
- Go to your resource in the Portal
- Locate the Export template
- Download the template to your local machine
- Using the Bicep CLI run:
az bicep decompile --file filename.json
This is especially useful to understand how it will look in Bicep if you need to troubleshoot something.
Closing thoughts
There’s a few ways to get some of the above information, you can grab the VM SKUs via CLI quite easily.
However, sometimes it’s just nice to understand the difference between a working example and what you’re trying to create to bridge that gap. Even more so when the docs lack information.
As mentioned, Bicep is rapidly being developed by Microsoft.
The monthly community calls they host are invaluable to be in the loop on news, new features, updates, roadmap but also be apart of helping feedback to drive features. You can sign up to the monthly invites here: https://aka.ms/armnews.
Latest Posts
APIOps – A deep dive for APIM multi-environments
Never miss an update: Azure Verified Modules with GitHub Bot & Teams
Getting started: Continuous deployment with Azure Bicep and Azure DevOps