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: 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.