GitHub Action for Project Bicep (ARM DSL)

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.

Wait what?

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).

Source: Azure/bicep

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:

  1. Consume bicep file (main.bicep).
  2. Build ARM json from bicep file.
  3. Deploy ARM json in Azure.


A bicep file looks like the following:

param location string = 'eastus'
param name string = '3on4oivnio43das'
var storageSku = 'Standard_LRS'
resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: name
location: location
kind: 'Storage'
sku: {
name: storageSku
output storageId string =
view raw main.bicep hosted with ❤ by GitHub

With the help of the Bicep CLI you can compile a bice file into an ARM template:

bicep build ./main.bicep

The GitHub Workflow looks like the following:

name: bicep
branches: [ v1 ]
branches: [ master ]
runs-on: ubuntu-latest
uses: actions/checkout@v2
name: Azure Login
uses: segraef/azlogin@v1
clientId: "${{ secrets.clientId }}"
clientSecret: "${{ secrets.clientSecret }}"
tenantId: "${{ secrets.tenantId }}"
subscriptionId: "${{ secrets.subscriptionId }}"
name: Bicep build and deploy
uses: segraef/bicep@v1
bicepFile: main.bicep
location: eastus
rg: bicep-rg
view raw workflow.yml hosted with ❤ by GitHub

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.

GitHub Workflow execution.
Finished example deployment of a storage account in Azure defined in main.bicep.

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.


Feel free to check out my other posts like Azure GitHub Actions and Wokflows or follow me on LinkedIn, Twitter and GitHub.

One thought on “GitHub Action for Project Bicep (ARM DSL)

Leave a Reply