How to search all VM images in Azure

Azure portal (code name Ibiza) is really cool, if you want to learn Azure or make some showcase. The problem is, that you will not find everything in the Portal. The great example is a daily build of your favourite Linux distribution - like Ubuntu 18.04 LTS which is not yet released today (as of February 27th). Does it mean that there is no 18.04 image in Azure? No.

What you need to do to find more images available is to use Azure CLI. The command we will use for VM images browsing is vm image. But first, we need to clarify some parameters:

  1. publisher - the company or entity behind the image.
  2. offer - this is the offering form the publisher.
  3. sku - Stock Keeping Unit is a id assigned to an image to identify the exact product version.

To list all publishers in West Europe Azure region we will perform:

az vm image list-publishers -l westeurope --query [].name -o tsv

To list all offers in West Europe Azure region from choosen publisher, let say Canonical, we will perform:

az vm image list-offers -l westeurope -p Canonical --query [].name -o tsv

To list all SKUs form UbuntuServer offer in West Europe Azure region we will perform:

az vm image list-skus -l westeurope -p Canonical -f UbuntuServer --query [].name -o tsv

Now we need to check how VM creation is performed from Azure CLI. Typically it looks like this:

az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS

where --image is: The name of the operating system image as a URN alias, URN, custom image name or ID, or VHD blob URI.

We are not using custom image or VHD and our image is not a standard, aliased image (like UbuntuLTS). So, we need to know image URN.
It's easy as:

az vm image list --all -p <publisher> -f <offer> -s <sku> -l <region>

Example for Ubuntu Server 18.04 LTS:

az vm image list --all -p Canonical -f UbuntuServer -s 18.04-DAILY-LTS -l westeurope

What we want to know is URN, so:

az vm image list --all -p Canonical -f UbuntuServer -s 18.04-DAILY-LTS -l westeurope --query [].urn -o tsv

The last part of the URN is an image version - you are probably looking for the last one. For 18.04 LTS daily builds, as for February 27th, we have:

Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802130
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802140
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802160
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802170
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802180
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802190
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802210
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802220
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802230
Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802240

If you want to create a VM from the last daily build's image, then:

az vm create -n MyVm -g MyResourceGroup --image Canonical:UbuntuServer:18.04-DAILY-LTS:18.04.201802240
comments powered by Disqus