Decompiling ARM to Bicep
What you'll learn: How to convert existing ARM JSON templates into cleaner Bicep syntax using the built-in decompile command.
Why Decompile?
You've likely inherited ARM templates written in verbose JSON or have existing infrastructure defined in ARM that you'd like to modernize. Rather than rewriting everything from scratch, Bicep provides a decompile command that translates ARM JSON into Bicep syntax automatically—like running your code through a translator that makes it more readable.
The Decompile Command
Use the Azure CLI or Bicep CLI to decompile an ARM template:
az bicep decompile --file template.json
This creates a template.bicep file in the same directory. The decompiler reads your JSON structure (resources, parameters, variables, outputs) and converts them into Bicep's cleaner syntax, removing much of the boilerplate.
Understanding Limitations
Decompiling isn't perfect—it's mechanical, not intelligent. The tool will:
- Convert syntax but may produce verbose or non-idiomatic Bicep
- Struggle with complex expressions nested deeply in ARM functions
- Add warnings as comments where manual review is needed
- Not optimize your code automatically
Think of it like using Google Translate: it gets you 80% of the way there, but you'll need to polish the output yourself. You might need to simplify expressions, extract reusable modules, or clean up variable names.
Post-Decompile Workflow
After decompiling, always review the generated .bicep file, test it with bicep build, and refactor for readability. The decompile command is your starting point, not your finish line.
Key Takeaway: The az bicep decompile command converts ARM JSON templates to Bicep syntax automatically, but always review and refine the output since the decompiler has limitations with complex expressions and doesn't optimize code style.