Virtual machine pre-publication testing

In this document, the scope of Azure Marketplace is China, and “mirror image” or “image” mean the same thing.

1. Set the VHD file URI (Uniform Resource Identifier) access rights

When the image is published on Azure Marketplace, an important field, OS Disk, must be filled in with the URI of the VHD file. Azure Marketplace needs to access these VHDs during the publishing and authentication process. This URI must be located in Azure Blob Storage, so you need to set the appropriate access rights.

To gain access rights to a VHD file, you should set the URI address for the VHD’s shared access signature (SAS) or the access policy for the storage container where the URI address is located to “Blob” or “container.”

For details of how to set the SAS URI, please refer to “ Method 1: Get the VM image shared access signature (SAS) URL from the Azure portal ” or “ Method 2: Get the SAS URL from Azure Storage Explorer .”

2. Virtual machine pre-publication testing

This section provides you with downloadable automated test scripts to help you test VMs automatically created from VHD files.

If you haven’t saved your VHD file in Azure Storage, upload the VHD to Azure and create a script for the virtual image. See Sample script to upload a VHD to Azure and create a new VM. (To make testing easier, you can download the PowerShell script below to test the VHD. Note: If you are unable to run the PowerShell script that you downloaded during testing, it might be because Windows has isolated it for security reasons. To resolve this issue, go to the Properties page for the script file, select Unblock to unblock the file, then run the script again.)

After you download the script, rename the file. For example: createvm.ps1.

Automatically create a virtual machine

.\createvm.ps1                  #Path to createvm.ps1 file
-resourcegroup <string>         #Resource groups name
-vhduri <string>                #vhd sas url link address
[-size <String>]                #VM size. Default:Standard_D1_v2
[-osLinuxOrWindows <String>]    #OS type. Linux 或 Windows。 Default:Linux  
[-ports <String>]               #Port. Default:linux:22,443,80, windows:3389,443,80
[-osusername <String>]          #VM UserName. Default:imtestuser
[-ospassword <String>]          #VM Password. Default:a@968^!Xm
[-location <String>]            #location.    Default:"China North"

Instance 1:

.\createvm.ps1 `
-resourcegroup rgname `
-vhduri ""

Instance 2:

.\createvm.ps1 `
-resourcegroup rgname `
-size Standard_D2_v2 `
-osLinuxOrWindows Windows `
-ports 3389,80 `
-osuername testuser `
-ospassword a@968^!Xm `
-location "China North 2"  `
-vhduri ""

The script “createvm.ps1” copies an existing VHD file, then automatically creates a new VM image in the Azure portal. If the VM image is created successfully, it means that the VHD image file has been prepared, and you can publish the VM image in the CPP (Cloud Partner Portal). (Note: Once testing is complete, the resource group where the virtual machine created in the test is located needs to be manually deleted.)

Next steps


  • If you have any questions about this documentation, please submit user feedback in the Azure Marketplace.
  • You can also look for solutions in the FAQs.