Previous Post in Series: Part 2: ARM Templates – A Walkthrough
Welcome back folks. Everything up until now has been preparation and creation, now we move on to the deployment.
ARM Template Deployment Methods
There are many ways and places to deploy your ARM templates from, we’re going to concentrate on 3 of the most common, these are:
- Deploying from the Azure portal https://portal.azure.com
- Deploying into Azure directly from GitHub
- Deploying using PowerShell
Azure Portal Deployment
- Log into https://portal.azure.com with the account we created in Part 1 of the guide, or use a pre-existing account with a valid subscription
- Click “+ New” and type “Template Deployment” into the search field
- Select “Template Deployment” and click “Create”
- Select “Build your own template in the editor”
- Click “Load file” and browse to your “azuredeploy.json” file
Once your template has been loaded in, you’ll see the left hand pane has been updated to show your “Parameters”, “Variables” and “Resources”.
- To deploy your template, click “Save”, you will now be prompted to enter values for the parameters within your template. Enter these as follows:
|Subscription||Choose your "Developer Program Benefit" subscription from the drop-down|
|Resource Group||Select "Create new" and enter a name for it, e.g. My-TestDev-RG|
|Location||Select a location for the resource group and ultimately where your resources will be deployed to. South Central US is a good go-to for this as it has all the services available we're going to deploy|
|_artifacts Location||Leave the default value|
|_artifacts Location SAS Token||Leave the default value (blank)|
|Customer Prefix ID||Enter a 5 character code for your customer, Cust1 will be used if not changed|
|Admin Username||Enter a username for the local administrator account configured on the deployed VMs|
|Admin Password||Enter a password for the above account|
|DNS Label Prefix||Enter a DNS name for the load balancer public IP address e.g. mytestdev (Must be lowercase) *1|
|Web Server VM Size||If you're using a "Developer Program Benefit" subscription, select "Standard_A1" from the drop-down *2|
|Number of Web Servers||If you're using a "Developer Program Benefit" subscription, select no more than 3 here *3|
|SQL Server VM Size||If you're using a "Developer Program Benefit" subscription, select Standard_DS1 here *4|
|Storage Account Type||Choose from the available options, basically HDD or SSD|
*1 – I’ll be updating the template at some point to force this to lowercase irrelevant of that the user inputs…I’ll get to it 🙂
*2 – There is a 4 core limit on this subscription so we have to work within those limits for our deployment
*3 – Same as above
*4 – Same as above, select 3 web VMs of size “Standard_A1” and a SQL VM of size “Standard_DS1” uses 4 cores
- Accept the license agreement and click “Purchase” to kick off your deployment. The template and your inputs will be validated before the job is submitted.
Assuming everything validates successfully, you should see a notification advising the deployment is in progress. There should be no issues here if you’ve made no changes to the template as I’ve confirmed it works before writing this guide.
The deployment will take a good while, go have a coffee! While you’re waiting, that “Deployment in Progress” is a link, feel free to click it for more information.
So that takes care of deployment method number 1, let’s have a look at our second option…PowerShell.
Let’s start by opening a PowerShell session, again, we’ll use PowerShell ISE here as everyone has it installed.
- Launch an elevated PowerShell ISE console
- Now paste the following code into the editor…NOT the PowerShell console under it.
# Deployment Variables $DeploymentName = "Modify this per deployment e.g. cust1" # Increment the number for subsequent deployments $RGName = "ResourceGroupName" $RGLocation = "southcentralus" # Change this as required $TemplatePath = "Enter the path to your ARM template e.g. C:\ARMTemplates\azuredeploy.json"</code> # Create new Resource Group for Template Deployment New-AzureRmResourceGroup -Name $RGName -Location $RGLocation # Deploy IISandSQL-ManDisksandAS ARM Template New-AzureRmResourceGroupDeployment -Name $DeploymentName ` -customerPrefixID "5 character customerID e.g. Cust1" ` -ResourceGroupName $RGName ` -TemplateFile $TemplatePath ` -adminUsername "AdministratorUsername" ` -adminPassword ("AdministratorPassword" | ConvertTo-SecureString -AsPlainText -Force) ` -dnsLabelPrefix "DNSLabelHere (Lowercase)" ` -webServerVMSize "Standard_A1" ` # Change as required, allowed values are listed in the template under parameter of the same name -numberOfWebServers 2 ` # Change as required, allowed values are listed in the template under parameter of the same name -sqlServerVMSize "Standard_DS1" ` # Change as required, allowed values are listed in the template under parameter of the same name -storageAccountType "Standard_LRS" # Change as required, allowed values are listed in the template under parameter of the same name
- Add values for the $DeploymentName, $RGName and $TemplatePath variables
- Update the -customerPrefixID, -adminUsername, -adminPassword and -dnsLabelPrefix parameter values
Before we can run the above code, we need to log into the Azure account we created earlier, the CMDLET for this part of the AzureRM PowerShell module. If you already have this install, just skip this step.
- In your PowerShell console, type the following:
You may receive a message advising the repository you’re downloading the module from is untrusted, select “Y” when prompted to continue with the download and installation.
Now let’s log in
A window will now pop up requesting your login credentials, enter those of the account we created in part 1 of the guide.
If you have multiple subscriptions within your Azure account, make sure you’re setup to deploy into the correct one. If you created our account while working through this guide your subscription name should be the same as below and you’re good to go.
You can swap between subscriptions by running the code below:
$MyAzureSubs = (Get-AzureRmSubscription).SubscriptionName ; $MyAzureSubs
NOTE: Ignore the warning 🙂
If you want to select the first subscription in the list, use the code below
Select-AzureRMSubscription -SubscriptionName $MyAzureSubs
You can select any other subscription stored in the $MyAzureSubs array by changing the number at the end of the above command.
NOTE: Remember the first item in the array is always assigned to zero or  as shown above
If at any point you want to check which subscription you’re currently signed into, run the following command
OK, now that we’re logged into our Azure account and have the correct subscription selected, let’s kick off our deployment but running the code we pasted into the editor and edited at the start of this section.
Like before, you can log into the Portal and check the deployment status if you feel the need 🙂
- Once logged into the portal, navigate to “Resource Groups”, “Your Resource Group” and click on “Deployments”
OK, so now we’ve covered a deployment from the Azure portal and from PowerShell. Let’s cover one more method.
Deploy Straight from GitHub
This last one doesn’t really need too much explanation but is worth pointing out as it’s pretty cool how easy it is to set up. Back in Part 2 we looked at the README.md file and it’s the URLs in that file that allow this to work.
To get started, log into the GitHub account we created back in Part 1 and browse to the template we uploaded.
- Click the button labelled “Deploy to Azure”
You’ll now be asked to log into the Azure Portal. Once logged in, you’ll be taken straight to the “Custom deployment” blade with the ARM template already loaded.
From here just populate the template as required, accept the license agreement and click “Purchase”.
So that’s it for our ARM Template walkthrough folks, as usual with my guides it ended up a little bigger than I was expecting but hopefully it’s the better for it. I hope to write more of these in future as I skill up myself.
See you in the next one 🙂