If you’ve landed here, odds are you are trying to find the SKUs or images available for your Microsoft Azure subscription and have already hit multiple pages referencing the outdated Get-AzureVMImage command. Things change quickly in the cloud and old data seems to linger for a while.
But have no fear. The information below outlines the commands to get the details on the Azure publisher, offer name, SKU Name and list all the VM images available based on location and subscription.
To find the needed information, first set the location; Central US in this example. Use the command below to find the location name if needed.
Get-AzureRmLocation | Select Location,DisplayName $locName = "centralus"
Next, I’ll run the command below to get the Publisher Names in the region I specified as the locName varialbl. This will be filtered to Windows publications only.
Get-AzureRmVMImagePublisher -Location $locName | where-object {$_.PublisherName -like "*windows*"} | ft PublisherName,Location
With that information, I’ll set my publisher name to Micorosft Windows Server
$pubName="MicrosoftWindowsServer"
Next, I list all the images offered by the Microsoft Windows Server publication with the command below.
Get-AzureRmVMImageOffer -Location $locName -PublisherName $pubName | ft Offer,PublisherName,Location
Based on the output from that command, I set the Image Offer to Windows Server
$offerName="WindowsServer"
After that, I run the following command to list the images available for the offer
Get-AzureRmVMImageSku -Location $locName -PublisherName $pubName -Offer $offerName | ft Skus,Offer,PublisherName,Location
And set the Sku to 2016-Datacenter
$skuName="2012-R2-Datacenter"
Lastly, use this command to list the images available for the SKU
Get-AzureRmVMImage -Location $locName -PublisherName $pubName -Skus $skuName -Offer $offerName