使用 Azure CLI 通过专用化映像版本创建 VMCreate a VM using a specialized image version with the Azure CLI
从共享映像库中存储的专用化映像版本创建 VM。Create a VM from a specialized image version stored in a Shared Image Gallery. 若要使用通用化映像版本创建 VM,请参阅从通用化映像版本创建 VM。If want to create a VM using a generalized image version, see Create a VM from a generalized image version.
在此示例中,请根据需要替换资源名称。Replace resource names as needed in this example.
使用 az sig image-definition list 列出库中的映像定义,以查看定义的名称和 ID。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
结合 --specialized 参数使用 az vm create 创建 VM 可以指明该映像是专用化映像。Create the VM using az vm create using the --specialized parameter to indicate the the image is a specialized image.
使用 --image
的映像定义 ID 从可用的最新映像版本创建 VM。Use the image definition ID for --image
to create the VM from the latest version of the image that is available. 还可以通过为 --image
提供映像版本 ID 从特定版本创建 VM。You can also create the VM from a specific version by supplying the image version ID for --image
.
在此示例中,我们将从 myImageDefinition 映像的最新版本创建 VM。In this example, we are creating a VM from the latest version of the myImageDefinition image.
az group create --name myResourceGroup --location chinaeast
az vm create --resource-group myResourceGroup \
--name myVM \
--image "/subscriptions/<Subscription ID>/resourceGroups/myGalleryRG/providers/Microsoft.Compute/galleries/myGallery/images/myImageDefinition" \
--specialized
后续步骤Next steps
此外可以使用模板创建共享映像库资源。You can also create Shared Image Gallery resource using templates. 提供多个 Azure 快速入门模板:There are several Azure Quickstart Templates available: