All ARM enthusiasts among us will now probably cry out and be happy. Microsoft announced a new ARM DSL, called Bicep. I won’t go into too much detail here, as I’m more into how to use a GitHub Action to use Bicep to generate an ARM template out of a .bice file. But let me give you some context to Bicep.
Bicep is a domain-specific language (DSL) for the declarative use of Azure resources. It simplifies the authoring experience with cleaner syntax and better support for modularity and code reuse. Bicep is a transparent abstraction over ARM and ARM templates, which means that everything that can be done in an ARM template can also be done in Bicep (outside the temporarily known limitations). All resource types, apiVersions and properties that are valid in an ARM template are equally valid on the first day in Bicep.
Bicep compiles down to standard ARM template JSON files, which means that the ARM JSON is effectively treated as an intermediate language (IL).
Where do I get started?
So that you can create your own bicep file I would recommend the easy installation anyway. For a quickstart, installation and usage of bicep start here.
GitHub Action Bicep
Now to the actual topic. I wrote you a GitHub Action which performs the following action:
- Consume bicep file (main.bicep).
- Build ARM json from bicep file.
- Deploy ARM json in Azure.
A bicep file looks like the following:
With the help of the Bicep CLI you can compile a bice file into an ARM template:
bicep build ./main.bicep main.json
The GitHub Workflow looks like the following:
Once your workflow and main.bicep is pushed/commited to your repository the workflow gets executed. After that, the GitHub Action segraef/bicep compiles your main.bicep into the ARM template and is being deployed into Azure using New-AzResourceGroupDeployment.
Yeah wow great and now?
This GitHub action is not a magic bullet and is just an experiment to play around with Bicep. But, this action has one advantage: The action only needs to be fed with a bicep file and will automatically deploy this bicep file to Azure.