Create a scale set using a specialized image version with the Azure CLI

Important

You can't currently create a Virtual Machine Scale Set using Flexible orchestration mode from an image shared by another tenant.

Create a scale set from a specialized image version stored in an Azure Compute Gallery. If you want to create a scale set using a generalized image version, see Create a scale set from a generalized image.

Important

When you create a new scale set from a specialized image, the VMs retain the computer name of the original VM. Other computer-specific information, like the CMID, is also kept. This duplicate information can cause issues. When using a specialized image, be aware of what types of computer-specific information your applications rely on.

Replace resource names as needed in these examples.

Creating a scale set using an image stored in an Azure Compute Gallery is the same as creating a scale set using a Marketplace image, except when you select an image, select See all images.

Screenshot showing how to select other image to use when creating a scale set.

The Select an image page will open. Select My images if the image you want is in your own gallery, or select Shared images if the image has been shared to you from someone else's gallery.

Screenshot showing where to select the type of image to use to create a scale set.

Important

Azure Compute Gallery – community galleries is currently in PREVIEW and subject to the Preview Terms for Azure Compute Gallery - community gallery.

Microsoft does not provide support for images in the community gallery.

You can create scale sets from images in the community gallery, but if the image is removed at a later time, you won't be able to scale up. To ensure you have long-term access to the image, you should consider creating an image in your own gallery from a VM created using the community gallery image that you want to use for your scale set. For more information, see Create an image definition and an image version.

As an end user, to get the public name of a community gallery, you need to use the portal. Go to Virtual machines > Create > Azure virtual machine > Image > See all images > Community Images > Public gallery name.

Replace resource names as needed in these examples.

If you choose to install and use the CLI locally, the community gallery requires that you are running the Azure CLI version 2.4.0 or later. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI.

To create a VM using an image shared to a community gallery, use the unique ID of the image for the --image which will be in the following format:

/CommunityGalleries/<community gallery name>/Images/<image name>/Versions/latest

To list all of the image definitions that are available in a community gallery using az sig image-definition list-community. In this example, we list all of the images in the ContosoImage gallery in West US and by name, the unique ID that is needed to create a VM, OS and OS state.

 az sig image-definition list-community \
   --public-gallery-name "ContosoImages-1a2b3c4d-1234-abcd-1234-1a2b3c4d5e6f" \
   --location westus \
   --query [*]."{Name:name,ID:uniqueId,OS:osType,State:osState}" -o table

Create the scale set by setting the --image parameter to the unique ID of the image in the community gallery. In this example, we are creating a Flexible scale set.

az group create --name myResourceGroup --location eastus

imgDef="/CommunityGalleries/ContosoImages-1a2b3c4d-1234-abcd-1234-1a2b3c4d5e6f>/Images/myLinuxImage/Versions/latest"

az vmss create \
   --resource-group myResourceGroup \
   --name myScaleSet \
   --image $imgDef \
   --orchestration-mode Flexible

When using a community image, you'll be prompted to accept the legal terms. The message will look like this:

To create the scale set from community gallery image, you must accept the license agreement and privacy statement: http://contoso.com. (If you want to accept the legal terms by default, please use the option '--accept-term' when creating VM/VMSS) (Y/n): 

Next steps

Azure Image Builder (preview) can help automate image version creation, you can even use it to update and create a new image version from an existing image version.

You can also create Azure Compute Gallery resource using templates. There are several Azure Quickstart Templates available: