Lots of the time when you see Azure Templates in the wild, they’re accompanied by “Deploy to Azure” buttons that allow you to click them and launches straight into Azure. You then enter any parameters and click deploy and you’re done. Unfortunately this doesn’t work for everyone – especially if you have multiple directories. I found that when clicking on these blue buttons I got launched into the wrong directory – making it impossible for me to deploy to the directory I wanted.
Fortunately it’s simple to deploy from a template without clicking on one of the magic blue buttons.
Step 1: Get your template
First off, find the template json file. This is the file that Azure loads in when you click on the magic deploy buttons. If you don’t know where this is then look at the source of the button and you’ll see something like this:
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-application-gateway-public-ip-ssl-offload%2Fazuredeploy.json"> <img style="max-width:100%;" data-canonical-src="http://azuredeploy.net/deploybutton.png" alt="Deploy to Azure" src="https://camo.githubusercontent.com/9285dd3998997a0835869065bb15e5d500475034/687474703a2f2f617a7572656465706c6f792e6e65742f6465706c6f79627574746f6e2e706e67"> </a>
Note that in the
<a> tag the
href attribute starts with “
https://portal.azure.com/#create/Microsoft.Template/uri/“. This is the link to azure. The remainder of the URI is the URL of the template json file. Copy the string after
/uri/ and url-decode it. You’ll get something like below:
Voila! Now paste that URL in your browser and copy the contents of the file.
Next go to the Azure portal (portal.azure.com) and click the “New” button. In the search box at the top type in “Template Deployment”, and select the first result with the same name in the search results. Click the blue “Create” button at the bottom of the next pane.
In the Custom Deployment Pane select “Edit Template”. Clear the text box and paste in the template you copied earlier. Click Save at the bottom.
Back in the Custom Deployment Pane finish specifying template Parameters, and other information such as resource group and region.
Once you finish entering information click Create and your template will be created in Azure, Huzzah!