我在一个资源组的“westus”位置有一个托pipe磁盘的虚拟机和该操作系统磁盘的快照。 现在,我正在尝试从快照创build另一个操作系统磁盘,但这一次,我为目标资源提供了“westus2”的位置。 在Azure CLI 2.0上,以下命令返回“未find实体”错误。
user @ ubuntu:az disk create -g myresgrp -n newsnapdisk -l westus2 --source /subscriptions/xxxxxxxxxxx/resourceGroups/myresgrp/providers/Microsoft.Compute/snapshots/mysnapshot 该实体没有find。
如果位置更改为“westus”而不是“westus2”,则该命令正常工作。 我找不到有关这个错误意味着什么的足够的文档,但是我已经validation了该命令中涉及的资源和资源组实际上存在。
是什么原因导致这个问题,我该如何克服这个问题?
在Azure上不支持从不同位置的快照创build磁盘。
您应该将快照复制到westus2存储帐户,然后您可以从存储帐户在westus2中创build一个快照。 你可以使用下面的脚本来做到这一点。
##generate SAS URI for a managed snapsho sasExpiryDuration=1800 sas=$(az snapshot grant-access --resource-group $resourceGroupName --name $snapshotName --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv) ##create storage account in westus2 and get the storage account key ##copy the snapshot to a storage account using SAS URI. az storage blob copy start --destination-blob $destinationVHDFileName --destination-container $storageContainerName --account-name $storageAccountName --account-key $storageAccountKey --source-uri $sas ##wait for a moment after the copy finished az snapshot create -g MyResourceGroup -n MySnapshot --source https://vhd1234.blob.core.windows.net/vhds/osdisk1234.vhd
只是一个例子,它适用于我。
sasExpiryDuration=1800 sas=$(az snapshot grant-access --resource-group shui2 --name shui --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv) az storage blob copy start --destination-blob shuitest.vhd --destination-container vhds --account-name shui123 --account-key ****** --source-uri $sas az snapshot create -g shui3 -n shui2 --source https://shui123.blob.core.windows.net/vhds/shuitest.vhd