Azure – Entity Not Found error while creating an OS disk from a Snapshot in different location in Azure

azureazure-active-directory

I've a Virtual Machine with managed disks and a snapshot of that OS Disk, in the "westus" location, in a resource group. Now, I'm trying to create another OS disk from the snapshot, but this time, I'm providing the location as "westus2" for the target resource. The following command returns with "The entity was not found" error on azure CLI 2.0.

user@ubuntu:az disk create -g myresgrp -n newsnapdisk -l westus2 --source /subscriptions/xxxxxxxxxxx/resourceGroups/myresgrp/providers/Microsoft.Compute/snapshots/mysnapshot
The entity was not found.

The command works fine if the location is changed to "westus" instead of "westus2". I cannot find enough documentation about what this error means, but I've verified that resources and resourcegroups involved in the command actually exist.

What is causing this issue and how do I Overcome this problem?

Best Answer

Creating a disk from a Snapshot in different location does not support on Azure.

You should copy the snapshot to westus2 storage account, then you could create a snapshot in westus2 from the storage account. You could use the following scripts to do this.

##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

Just an example below, it works for me.

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
Related Topic