Azure ARM deployment: test a template

Test-AzureRmResourceGroupDeployment -ResourceGroupName DWRG -TemplateFile .\SingleVMwithSQL.json


Here’s a gotcha: in editing a template, I completely forgot that you can only use lowercase letters and numbers for the names of storage accounts. That detail is only exposed (as far as I can see) by digging into the activity logs in the Portal

Azure ARM: naïve single VM deployment

The aim is to get a real simple VM deployment working using a json template, and in doing that to sacrifice any guidelines on authoring best practice, so we can focus on getting familiar with the nuts and bolts of ARM deployment.

Download the template and PowerShell helper from here.

Assume you need Windows 10 Anniversary edition PowerShell versions for these client/deployment actions.

Open a PowerShell admin prompt in the download location, and run [.\deploy.ps1].

You will be prompted for your Azure login, a resource group and location (e.g. “uksouth”), and an admin password for the VM.

If all goes fine, then you will be able to rdp to the VM, and be able to start up SSMS.

Finally, a couple of pictures I took to focus the mind when trying to reduce the template to the bare minimum to get a working VM:

The next day… in fact I have started to remove the literals as I get more familiar. Again, I refer you the MS Azure docs above.

Azure ARM: listing the images available to your subscription

I need to identify the images that are available to my subscription. For example, if I want an image that gives me SQL Server 2016, short of Googling, how do I find that?

I seem to remember that this was kind of easy in the Classic Azure deployment model, but I am now using Azure Resource Manager (ARM), and I don’t wish to return to Classic, i.e. legacy, which is not where the development effort is being invested.

For my use-case, I need to inject the answer (identifying the available images) into a ARM deployment template, but I think it applies to any use-case where you need to identify the images that are available to your subscription.

These are the parts of the template that I need to populate with the answer, namely Publisher (most significant part of the sort), Offer, and Sku. Right now their default values are those in blue in the json extract.

"imagePublisher": {
 "type": "string",
 "defaultValue": "MicrosoftWindowsServer",
 "metadata": {
 "description": "Image Publisher"

"imageOffer": {
 "type": "string",
 "defaultValue": "WindowsServer",
 "metadata": {
 "description": "Image Offer"

"imageSKU": {
 "type": "string",
 "defaultValue": "2012-R2-Datacenter",
 "metadata": {
 "description": "Image SKU"

But as said I want a set that gives me some flavour of SQLServer 2016. Getting the right values is not as simple as running a built-in Azure PowerShell function. Oh no. There are some hoops to go through.

Once you have logged into your subscription, these are the steps:

1. Find the publisher. But how do I know which is the publisher I need? For me that is quite easy as it is usually some variation on Microsoft. But using the Out-GridView PS function will help.  I also need to specify a location. So we can start with this:

Get-AzureRmVMImagePublisher -Location uksouth | Out-GridView

Looking at the result of that below, after playing with the search filter, then I see my likely Publisher is [MicrosoftSQLServer].

So I can refine my query to this and stick the object output in a variable:

$publisher = Get-AzureRmVMImagePublisher -Location uksouth | ? {$_.PublisherName -like "*microsoftsql*"}

2. Find the offer.

Get-AzureRmVMImageOffer -Location "uksouth" -PublisherName $publisher.PublisherName

3. Find the SKU

Now I have my likely offer (SQL2016SP1-WS2016), my publisher (MicrosoftSQLServer), and now I need the sku:

Get-AzureRmVMImageSku -Location "uksouth" -PublisherName "MicrosoftSQLServer"  -Offer "SQL2016SP1-WS2016"

With those 3 answers (plus the location, which also comes into play), I can update the json:

The steps to deploy the template will be another post, but right now, as I chose Express, this is what I see in the created VM:


Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64)   Oct 28 2016 18:17:30   Copyright (c) Microsoft Corporation  Express Edition (64-bit) on Windows Server 2016 Datacenter 6.3 <X64> (Build 14393: ) (Hypervisor)

Azure RMVM: January 2017

I will try not to make a habit of this, but zero context as I am done. Gist is here.

Azure ARM: MVA course

Useful ARM course here, for free.


Example they use on GitHub here.

Hm… I dumbly/deliberately pasted their example command line, knowing it would break, but not why:


New-AzureResourceGroupDeployment : The term 'New-AzureResourceGroupDeployment' is not recognized...

Fascinating. So they are using the Classic model.

If I now use


and not


, then I get this:


New-AzureRmResourceGroupDeployment : Could not find file 'C:\WINDOWS\system32\2VMsinVnetWithILB.json'

, which is fine.

So having cloned their repo, I then started using their example in anger.

Error 1: “GEN-UNIQUE is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.”

OK, so find and fix that:


Error 2:  “target”: “adminPassword”, “message”: “The supplied password must be between 8-123 characters long and must satisfy at least 3 of password complexity requirements from the following: \r\n1)
Contains an uppercase character\r\n2) Contains a lowercase character\r\n3) Contains a numeric digit\r\n4) Contains a special character.”

Same file – easy enough…

And after 5 minutes or so, I had a new deployment running in the Azure Portal. Great!


There is a Visualizer as well. I’ll dig into that another time. There is a new version… which looks a bit broken to me.

Azure: deployment using templates

The goal here is to get from an Azure subscription with no VMs etc, to a working VM to which we can immediately RDP and use.

Repeating some of the steps taking you from a bare (Windows) client machine to the working VM

  • Install-Module AzureRM (Windows client)
  • Login-AzureRmAccount (logs you in to your Azure account) 
  • Set-AzureRmContext (vital for me as I have 2 subscriptions),
    e.g. Set-AzureRmContext -SubscriptionName “Visual Studio Ultimate with MSDN”

Find this file (temp/templates / ref2.json) on Github and save it to your working location. It will be referenced in the next command. (I know it all needs tidying up)

Create a resource group by executing this command in a PowerShell admin prompt (altering Name and Location as you wish).

New-AzureRmResourceGroup -Name DWRG -Location "UK South"


Execute this command in a PowerShell admin prompt, which will generate your VM (with an assumption that [ref2.json] is in the current folder), and the supporting structure. It will still prompt for the admin password for the VM(s). Note that the storageAccountName value must be lower case.

New-AzureRmResourceGroupDeployment -Name DWDeploy -ResourceGroupName
DWRG -TemplateFile .\ref2.json -storageAccountName "dwstorage" 
-virtualNetworkName "DWVnn" -networkInterfaceName "DWNin" 
 -adminUsername "TheAdmin" -vmName "DWVm"

And this is the kind of output you can expect:


And finally proof I can jump onto that Windows Server 2012.


I intend to reduce the content of the ref2.json file to the bare minimum to get a set of VMs. I have already removed the load balancer references (this is just for functional testing purposes), and will remove the availability set references once I work out the dependencies.