Finding a VM Image Reference, Publisher & SKU

craftsman-3008031_640Automation is great.

I love to script solutions in Azure.

But most of the time, that automation started with me fumbling and trialing different approaches in the portal.  Once I got something around what I wanted I’ll automate.

I suspect you do the same thing.

This is why today we’re going to look at how to find the image reference of your favorite VM images in the Azure Market Place.

For instance, when you look at some ARM template, how does the author found this piece of JSON?

"Image Reference": {
"publisher": "OpenLogic",
"offer": "CentOS",
"sku": "7.3",
"version": "latest"

We’ll look at a few ways to find that, both in the Portal and in PowerShell.

From the Azure Marketplace

Let’s assume we already found the VM image in the Azure Marketplace.

For instance, let’s say we like the Data Science Virtual Machine published by Microsoft.


Well, let’s create one.  Or at least, let’s pretend we will create one.  Let’s fill all the sections to create the VM.

We won’t create it, so let’s not bother about configuring availability set and VNETs and choosing a great name for the administrator.  Let’s just type enough stuff to get pass the validation gate.


At the last step, instead of clicking Create, right next to it is Download Template and parameters.  Let’s click that.

We are taken to an ARM template visualizer.  This is the ARM template the Portal would run for us if we would hit “create”.

On the left-hand side menu, let’s open the Resources node and look for the VM icon & click on it.


Scrolling down we should find the storageProfile JSON node and the imageReference under it.  This is what we are looking for:

"imageReference": {
"publisher": "microsoft-ads",
"offer": "windows-data-science-vm",
"sku": "windows2016",
"version": "latest"

Boom.  Pause for effect.

Existing Deployment

Now let’s assume that we do not remember what image we choose.  We did that a few months ago, it still is in our Azure subscription but we got no idea what exact image we picked.

No worries.  Let’s go to the resource group where that VM is hiding.


Let’s select the Deployments tab.  This shows us the list of deployments (ARM Template deployments that is) that has occurred in that resource group.


Here the initial deployment is more than 2 months old.

In the example above we have a few deployments because there is more than one VM in that resource group.  The deployment name should tip us into what they are about.  Here, let’s select the RedHat one.


We can see some deployment details.  On the top right have this View template button.  It will lead us to the ARM template used in this deployment.

From there, we can find what we are looking for the same way we did in the previous section.

Using PowerShell

Now it might be interesting to explore the quadruple (i.e. publisher, offer, sku, version) and some variations.  For that scripting is required.  Let’s start with PowerShell.

First, we’ll need to target an Azure region.  Easy enough, let’s choose.

Get-AzureRmLocation | select Location

Let’s say we choose northcentralus (North Central USA).  We can now look at the publishers available in that region.

$location = "northcentralus"

Get-AzureRmVMImagePublisher -Location $location

We might want to narrow it down.  For example we might want to look at only Microsoft-related ones

Get-AzureRmVMImagePublisher -Location $location | where {$_.PublisherName.Contains("microsoft")}

which gives us a shorter list.


(Actually, this is for Microsoft in lower-case specifically ; if we want anything Microsoft the filter would be $_.PublisherName.ToLower().Contains(“microsoft”) and returns a much longer list)

Let’s say we choose microsoft-ads.  We can look at the offering of that publisher.

$publisher = "microsoft-ads"

Get-AzureRmVMImageOffer -Location $location -PublisherName $publisher


Let’s say we picked the first one and look at the different skus available.

$offer = "linux-data-science-vm"

Get-AzureRmVMImageSku -Location $location -PublisherName $publisher -Offer $offer


Again, let’s say we picked the first one, we can now look at all the versions available:

$sku = "linuxdsvm"

Get-AzureRmVMImage -Location $location -PublisherName $publisher -Offer $offer -Skus $sku


Usually we simply specify “latest” for the version, but it could be useful to know which versions are available.

So now we have it, within a location we got the quadruple ($publisher, $offer, $sku, $version).


VM Image Reference seem to be one of those magic element that just falls on the lap of the worthy.  But as we’ve shown, there is nothing mysterious about them.

We can easily reverse engineer the image reference from something we’ve already created in the portal and we can also explore the offerings using PowerShell scripts.

2 responses

  1. Samit 2018-08-14 at 05:32


    Using the above solution can we find what is the OS build number. I am looking to list all the existing Azure VM’s and respective OS build number.

  2. Vincent-Philippe Lauzon 2018-08-14 at 06:08

    Not that I know of.

    Are you looking for Azure VMs or Azure VM Images?

    If it’s the latter, I don’t think there is meta data for OS build number. If it’s the former, you could implement your own tagging using Azure tags and then query Azure to find all VMs having a specific tag…

Leave a comment