Create a scale set from a generalized image with Azure CLI
Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Uniform scale sets
Create a scale set from a generalized image version stored in an Azure Compute Gallery using the Azure CLI. If want to create a scale set using a specialized image version, see Create scale set instances from a specialized image.
If you choose to install and use the CLI locally, this tutorial 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.
Replace resource names as needed in this example.
List the image definitions in a gallery using az sig image-definition list to see the name and ID of the definitions.
resourceGroup=myGalleryRG
gallery=myGallery
az sig image-definition list \
--resource-group $resourceGroup \
--gallery-name $gallery \
--query "[].[name, id]" \
--output tsv
Create the scale set using az vmss create.
Use the image definition ID for --image to create the scale set instances from the latest version of the image that is available. You can also create the scale set instances from a specific version by supplying the image version ID for --image. Be aware that using a specific image version means automation could fail if that specific image version isn't available because it was deleted or removed from the region. We recommend using the image definition ID for creating your new VM, unless a specific image version is required.
In this example, we are creating instances from the latest version of the myImageDefinition image.
az group create --name myResourceGroup --location eastus
az vmss create \
--resource-group myResourceGroup \
--name myScaleSet \
--image "/subscriptions/<Subscription ID>/resourceGroups/myGalleryRG/providers/Microsoft.Compute/galleries/myGallery/images/myImageDefinition"
--admin-username azureuser \
--generate-ssh-keys
It takes a few minutes to create and configure all the scale set resources and VMs.
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:
- Create an Azure Compute Gallery
- Create an Image Definition in an Azure Compute Gallery
- Create an Image Version in an Azure Compute Gallery
For more information about Shared Image Galleries, see the Overview. If you run into issues, see Troubleshooting shared image galleries.