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](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-storage-account-create%2Fazuredeploy.json)
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 https://portal.azure.com/#create/Microsoft.Template/uri) that does this for us.
Asked by Matthias Güntert
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
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 https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64 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: EndBugfirstname.lastname@example.org with: author_name: github-actions author_email: '41898282+github-actions[bot]@users.noreply.github.com' 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 https://stackoverflow.com/questions/66645149/how-to-create-a-deploy-to-azure-button-that-uses-a-bicep-instead-of-an-json-te