Find and use VM images in the Azure Marketplace with Azure PowerShell

This article describes how to use Azure PowerShell to find VM images in the Azure Marketplace. You can then specify a Marketplace image when you create a VM.

You can also browse available images and offers using the Azure Marketplace storefront, the Azure portal, or the Azure CLI.


A Marketplace image in Azure has the following attributes:

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

To identify a Marketplace image when you deploy a VM programmatically, supply these values individually as parameters. Some tools accept an image URN, which combines these values, separated by the colon (:) character: Publisher:Offer:Sku:Version. In a URN, you can replace the version number with "latest", which selects the latest version of the image.

If the image publisher provides additional license and purchase terms, then you must accept those terms and enable programmatic deployment. You'll also need to supply purchase plan parameters when deploying a VM programmatically. See Deploy an image with Marketplace terms.

Table of commonly used Windows images

This table shows a subset of available Skus for the indicated Publishers and Offers.

Publisher Offer Sku
MicrosoftWindowsServer WindowsServer 2019-Datacenter
MicrosoftWindowsServer WindowsServer 2019-Datacenter-Core
MicrosoftWindowsServer WindowsServer 2019-Datacenter-with-Containers
MicrosoftWindowsServer WindowsServer 2016-Datacenter
MicrosoftWindowsServer WindowsServer 2016-Datacenter-Server-Core
MicrosoftWindowsServer WindowsServer 2016-Datacenter-with-Containers
MicrosoftWindowsServer WindowsServer 2012-R2-Datacenter
MicrosoftWindowsServer WindowsServer 2012-Datacenter
MicrosoftSharePoint MicrosoftSharePointServer sp2019
MicrosoftSQLServer SQL2019-WS2016 Enterprise
MicrosoftRServer RServer-WS2016 Enterprise

One way to find an image in a location is to run the Get-AzVMImagePublisher, Get-AzVMImageOffer, and Get-AzVMImageSku cmdlets in order:

  1. List the image publishers.
  2. For a given publisher, list their offers.
  3. For a given offer, list their SKUs.

Then, for a selected SKU, run Get-AzVMImage to list the versions to deploy.

  1. List the publishers:

    $locName="<Azure location, such as West US>"
    Get-AzVMImagePublisher -Location $locName | Select PublisherName
  2. Fill in your chosen publisher name and list the offers:

    Get-AzVMImageOffer -Location $locName -PublisherName $pubName | Select Offer
  3. Fill in your chosen offer name and list the SKUs:

    Get-AzVMImageSku -Location $locName -PublisherName $pubName -Offer $offerName | Select Skus
  4. Fill in your chosen SKU name and get the image version:

    Get-AzVMImage -Location $locName -PublisherName $pubName -Offer $offerName -Sku $skuName | Select Version

From the output of the Get-AzVMImage command, you can select a version image to deploy a new virtual machine.

The following example shows the full sequence of commands and their outputs:

$locName="West US"
Get-AzVMImagePublisher -Location $locName | Select PublisherName

Partial output:


For the MicrosoftWindowsServer publisher:

Get-AzVMImageOffer -Location $locName -PublisherName $pubName | Select Offer



For the WindowsServer offer:

Get-AzVMImageSku -Location $locName -PublisherName $pubName -Offer $offerName | Select Skus

Partial output:


Then, for the 2019-Datacenter SKU:

Get-AzVMImage -Location $locName -PublisherName $pubName -Offer $offerName -Sku $skuName | Select Version

Now you can combine the selected publisher, offer, SKU, and version into a URN (values separated by :). Pass this URN with the --image parameter when you create a VM with the New-AzVM cmdlet. You can optionally replace the version number in the URN with "latest" to get the latest version of the image.

If you deploy a VM with a Resource Manager template, then you'll set the image parameters individually in the imageReference properties. See the template reference.

Deploy an image with Marketplace terms

Some VM images in the Azure Marketplace have additional license and purchase terms that you must accept before you can deploy them programmatically.

To deploy a VM from such an image, you'll need to both accept the image's terms and enable programmatic deployment. You'll only need to do this once per subscription. Afterward, each time you deploy a VM programmatically from the image you'll also need to specify purchase plan parameters.

The following sections show how to:

  • Find out whether a Marketplace image has additional license terms
  • Accept the terms programmatically
  • Provide purchase plan parameters when you deploy a VM programmatically

View plan properties

To view an image's purchase plan information, run the Get-AzVMImage cmdlet. If the PurchasePlan property in the output is not null, the image has terms you need to accept before programmatic deployment.

For example, the Windows Server 2016 Datacenter image doesn't have additional terms, so the PurchasePlan information is null:

$version = "2016.127.20170406"
Get-AzVMImage -Location $locName -PublisherName $pubName -Offer $offerName -Skus $skuName -Version $version


Id               : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Providers/Microsoft.Compute/Locations/westus/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/2019.0.20190115
Location         : westus
PublisherName    : MicrosoftWindowsServer
Offer            : WindowsServer
Skus             : 2019-Datacenter
Version          : 2019.0.20190115
FilterExpression :
Name             : 2019.0.20190115
OSDiskImage      : {
                     "operatingSystem": "Windows"
PurchasePlan     : null
DataDiskImages   : []

The example below shows a similar command for the Data Science Virtual Machine - Windows 2016 image, which has the following PurchasePlan properties: name, product, and publisher. Some images also have a promotion code property. To deploy this image, see the following sections to accept the terms and to enable programmatic deployment.

Get-AzVMImage -Location "westus" -PublisherName "microsoft-ads" -Offer "windows-data-science-vm" -Skus "windows2016" -Version "0.2.02"


Id               : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Providers/Microsoft.Compute/Locations/westus/Publishers/microsoft-ads/ArtifactTypes/VMImage/Offers/windows-data-science-vm/Skus/windows2016/Versions/19.01.14
Location         : westus
PublisherName    : microsoft-ads
Offer            : windows-data-science-vm
Skus             : windows2016
Version          : 19.01.14
FilterExpression :
Name             : 19.01.14
OSDiskImage      : {
                     "operatingSystem": "Windows"
PurchasePlan     : {
                     "publisher": "microsoft-ads",
                     "name": "windows2016",
                     "product": "windows-data-science-vm"
DataDiskImages   : []

Accept the terms

To view the license terms, use the Get-AzMarketplaceterms cmdlet and pass in the purchase plan parameters. The output provides a link to the terms for the Marketplace image and shows whether you previously accepted the terms. Be sure to use all lowercase letters in the parameter values.

Get-AzMarketplaceterms -Publisher "microsoft-ads" -Product "windows-data-science-vm" -Name "windows2016"


Publisher         : microsoft-ads
Product           : windows-data-science-vm
Plan              : windows2016
LicenseTextLink   :
PrivacyPolicyLink :
Accepted          : False
Signdate          : 1/25/2019 7:43:00 PM

Use the Set-AzMarketplaceterms cmdlet to accept or reject the terms. You only need to accept terms once per subscription for the image. Be sure to use all lowercase letters in the parameter values.

$agreementTerms=Get-AzMarketplaceterms -Publisher "microsoft-ads" -Product "windows-data-science-vm" -Name "windows2016"

Set-AzMarketplaceTerms -Publisher "microsoft-ads" -Product "windows-data-science-vm" -Name "windows2016" -Terms $agreementTerms -Accept


Publisher         : microsoft-ads
Product           : windows-data-science-vm
Plan              : windows2016
LicenseTextLink   :
PrivacyPolicyLink :
Accepted          : True
Signdate          : 2/23/2018 7:49:31 PM

Deploy using purchase plan parameters

After accepting the terms for an image, you can deploy a VM in that subscription. As shown in the following snippet, use the Set-AzVMPlan cmdlet to set the Marketplace plan information for the VM object. For a complete script to create network settings for the VM and complete the deployment, see the PowerShell script examples.


$vmConfig = New-AzVMConfig -VMName "myVM" -VMSize Standard_D1

# Set the Marketplace plan information

$publisherName = "microsoft-ads"

$productName = "windows-data-science-vm"

$planName = "windows2016"

$vmConfig = Set-AzVMPlan -VM $vmConfig -Publisher $publisherName -Product $productName -Name $planName


$vmConfig = Set-AzVMOperatingSystem -Windows -VM $vmConfig -ComputerName "myVM" -Credential $cred

# Set the Marketplace image

$offerName = "windows-data-science-vm"

$skuName = "windows2016"

$version = "19.01.14"

$vmConfig = Set-AzVMSourceImage -VM $vmConfig -PublisherName $publisherName -Offer $offerName -Skus $skuName -Version $version

You'll then pass the VM configuration along with network configuration objects to the New-AzVM cmdlet.

Next steps

To create a virtual machine quickly with the New-AzVM cmdlet by using basic image information, see Create a Windows virtual machine with PowerShell.

For more information on using Azure Marketplace images to create custom images in a shared image gallery, see Supply Azure Marketplace purchase plan information when creating images.