Query Azure Marketplace image URN with PowerShell

A Marketplace image URN in Azure has the following attributes:

  • Publisher - The organization that created the image. Examples: Canonical, MicrosoftWindowsServer
  • Offer - Name of a group of related images created by a publisher. Examples: Ubuntu Server, WindowsServer
  • SKU - An instance of an offer, such as a major release of a distribution. Examples: 18.04-LTS, 2016-Datacenter
  • Version - The version number of an image SKU.

If you are developing or using an application that need to access the Azure Marketplace image, you would need to use image URNs. Following is the steps to indentify an image URN

First of all, let’s import the required module

Import-Module AzureRM.Compute

Then set location variable for later queries

$location="Southeast Asia"

Now we can start query from Azure API
Get list of publisher from location above

Get-AzureRMVMImagePublisher -Location $location | Select PublisherName

Get list of offer from that Publisher

Get-AzureRMVMImageOffer -Location $location -Publisher $publisher | Select Offer

Get list of sku from that Offer

Get-AzureRMVMImageSku -Location $location -Publisher $publisher -Offer $offer | Select Skus

Get list of image from that SKU

Get-AzureRMVMImage -Location $location -Publisher $publisher -Offer $offer -Sku $sku | Select Version

Ok, here we go, with the version in the last query, we can have image URN as MicrosoftWindowsServer:WindowsServer:2016-Datacenter:2016.127.20180613

Share Comments