Coder Perfect

How do I make a “Deploy to Azure” button with a bicep rather than a JSON template?


When using plain JSON ARM templates we are able to create a Deploy to Azure button by embedding a link following this format:

[![Deploy to Azure](](

As a consequence, you’ll have a simple action that even works on Stackoverflow.

Nice! But how can bicep templates help you attain the same goal?

It’s not enough to simply replace the URL encoded section with a bicep file. I’m aware that bicep performs a transpilation and generates an ARM template based on JSON.

However, as we are able to use the Azure CLI to directly deploy a bicep file, there might be another endpoint (like that does this for us.

Asked by Matthias Güntert

Solution #1

This is not currently supported by Portal.

You may utilize the bicep build output and connect the deploy button to the json file as a workaround (this is what we’ll be doing in the QuickStart repo until portal supports bicep natively).

It’s not ideal, but it’s a snapshot in time…

Answered by bmoore-msft

Solution #2

Meanwhile, in a project of mine, I constructed a GitHub workflow that generates an ARM template file based on the Bicep template and commits it to the repository ‘automatically’ using the Add&Commit action.

This is a basic workflow example:

- name: Install Bicep build
  run: |
    curl -Lo bicepinstall
    chmod +x ./bicepinstall
    sudo mv ./bicepinstall /usr/local/bin/bicep
    bicep --help

- name: Run Bicep build
  run: |
    bicep build deploy/main.bicep
    ls -l deploy/*.json

- uses: EndBug/add-and-commit@v7.0.0
    author_name: github-actions
    author_email: '41898282+github-actions[bot]'
    message: Update Bicep-ARM template
    add: deploy/main.json

Then, as described by bmoore-msft, you may place a regular Deploy button in the Readme file.

Answered by Giorgio Lasala

Post is based on