Searching VM Images in Azure

The Azure Portal provides search capability allowing quick review and selection of a desired VM image. But when deploying via the Azure CLI or template you must know some parameters to specify the image to be deployed. This post provides a few examples showing how to search the image listing via the Azure CLI.

Examples below were created using the Azure Cloud Shell but can be run on any Linux system with the Azure CLI installed. Full documentation referenced for this post can be found in the Azure Docs.

Images in Azure are specified by a Publisher, Offer, SKU, and a Version. These can be specified as individual CLI arguments, or joined by a colon (‘:’) to form a URN. Finding the right image starts with knowing the Publisher, which is typically the company name though you may still need to list providers to find the correct representation. For example, if we’re interested in Ubuntu images we probably want to look for ‘Canonical’:

ed@Azure:~$ az vm image list-publishers -l eastus2 | grep -i canonical
    "id": "/Subscriptions/{removed}/Providers/Microsoft.Compute/Locations/eastus2/Publishers/Canonical",
    "name": "Canonical",
ed@Azure:~$

The default output of Azure CLI is JSON. Other output formats are available (use the -h argument to see available types). The table type is fairly human-readable in this case. Also, I have piped the output to the Linux command grep but the Azure CLI offers a more powerful and flexible way to filter the output: JMESPath. I may blog more on this later as it can filter and transform the output, but for now we’ll stick to some simple filters:

ed@Azure:~$ az vm image list-publishers -l eastus2 --query "[?contains(name, 'anonical')]"
[
  {
    "id": "/Subscriptions/{removed}/Providers/Microsoft.Compute/Locations/eastus2/Publishers/Canonical",
    "location": "eastus2",
    "name": "Canonical",
    "tags": null
  }
]
ed@Azure:~$

Maybe Canonical was too straight-forward. Let’s look for images published by F5 Networks, since we may not know how they are represented when the name includes a space.

ed@Azure:~$ az vm image list-publishers -l eastus2 --query "[?contains(name, 'f5')]"
[
  {
    "id": "/Subscriptions/{removed}/Providers/Microsoft.Compute/Locations/eastus2/Publishers/f5-networks",
    "location": "eastus2",
    "name": "f5-networks",
    "tags": null
  }
]
ed@Azure:~$

Now that we have the right Publisher, let’s look at their Offers. Use table output for readability.

ed@Azure:~$ az vm image list-offers -l eastus2 -p canonical -o table
Location Name
---------- -----------------------
eastus2 Ubuntu15.04Snappy
eastus2 Ubuntu15.04SnappyDocker
eastus2 UbunturollingSnappy
eastus2 UbuntuServer
eastus2 Ubuntu_Core
ed@Azure:~$

Each Offer may have a number of SKUs available. Let’s look at the SKUs for UbuntuServer.

ed@Azure:~$ az vm image list-skus -l eastus2 -p canonical -f ubuntuserver -o table
Location Name
---------- -----------------
{some output removed}
eastus2 17.10-DAILY
eastus2 18.04-DAILY-LTS
eastus2 18.04-LTS
eastus2 18.10
eastus2 18.10-DAILY
eastus2 19.04-DAILY
ed@Azure:~$

Finally you can list versions by using the ​--all argument:

ed@Azure:~$ az vm image list --all -p canonical -f ubuntuserver -s 18.04-lts -o table
Offer Publisher Sku Urn Version
------------ ----------- --------- ------------------------------------------------ ---------------
{some output removed}
UbuntuServer Canonical 18.04-LTS Canonical:UbuntuServer:18.04-LTS:18.04.201810030 18.04.201810030
UbuntuServer Canonical 18.04-LTS Canonical:UbuntuServer:18.04-LTS:18.04.201810240 18.04.201810240
UbuntuServer Canonical 18.04-LTS Canonical:UbuntuServer:18.04-LTS:18.04.201810290 18.04.201810290
UbuntuServer Canonical 18.04-LTS Canonical:UbuntuServer:18.04-LTS:18.04.201811010 18.04.201811010
ed@Azure:~$

When deploying an image you can use the keyword latest to deploy the latest version. I’m not certain of the difference between image versions – perhaps later versions incorporate package updates limiting the amount of updating required post-deployment. Notice the column for URN in the version list. It’s a fully-specified image by combining Publisher, Offer, SKU, and Version into one string. View the latest version of the Ubuntu Server 18.04-LTS image as an example.

ed@Azure:~$ az vm image show -l eastus2 --urn canonical:ubuntuserver:18.04-lts:latest
{
"automaticOsUpgradeProperties": {
"automaticOsUpgradeSupported": false
},
"dataDiskImages": [],
"id": "/Subscriptions/{removed}/Providers/Microsoft.Compute/Locations/eastus2/Publishers/canonical/ArtifactTypes/VMImage/Offers/ubuntuserver/Skus/18.04-lts/Versions/18.04.201811010",
"location": "eastus2",
"name": "18.04.201811010",
"osDiskImage": {
"operatingSystem": "Linux"
},
"plan": null,
"tags": null
}
ed@Azure:~$

By using the image listing functions in the Azure CLI you can find the right parameters to fully specify an image for your CLI or template deployment.

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: