Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
383 stars 1.24k forks source link

az image copy doesn't allow copy images across regions with snapshots attached #1920

Open aamorale opened 4 years ago

aamorale commented 4 years ago

Please include a note that mention about a possible failure if the VM Image has Snapshots attached since it will not possible changing the property "sourceuri" for the snapshot of a managed disk. Please refer the following example:

command failed: ['/usr/local/xxxx/azure-cli/2.2.0_1/libexec/bin/python', '-m', 'azure.cli', 'snapshot', 'create', '--resource-group', 'image-copy-rg', '--name', 'image-20200422_os_disk_snapshot-eastus', '--location', 'eastus', '--source', 'https://eastusx3245an0rwlifpkzay.blob.core.windows.net/snapshots/image-20200422_os_disk_snapshot.vhd', '--source-storage-account-id', '/subscriptions/SubscriptionID/resourceGroups/image-copy-rg/providers/Microsoft.Storage/storageAccounts/storageacountname', '--output', 'json', '--tags', 'created_by=image-copy-extension'] output: ERROR: Changing property 'sourceUri' is not allowed for existing disk 'aura-aes-image-20200422_os_disk_snapshot-eastus'.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

yungezz commented 4 years ago

hi @qwordy could you pls have a look?

qwordy commented 4 years ago

Known issue. And it doesn't support image with data disks. You may want to try shared image gallery.

kgfly commented 3 years ago

I hit an weird issue. I ran 2 cmds.

_az image copy --source-resource-group XXX --source-object-name YYY-image --source-type image --target-location eastus --target-resource-group "XXX" --target-name YYY-eastus

az image copy --source-resource-group XXX --source-object-name YYY-image --source-type image --target-location eastus2 --target-resource-group "XXX" --target-name YYY-eastus2_

2nd passed, while 1st failed with:

Output: Changing property 'sourceUri' is not allowed for existing disk 'YYY-image_os_disk_snapshot-eastus'.

What could be the reason?

zhoxing-ms commented 3 years ago

@kgflying Could you please send me the debug log via email? Please add parameter --debug after the executed commands, and then send the printed email to me. My email address is Zhou.Xing@microsoft.com

kgfly commented 3 years ago

@zhoxing-ms , I've sent you the log. Thanks for helping!

zhoxing-ms commented 3 years ago

@kgflying This issue seems to be a problem in creating snapshot in target region from the copied blob. Could you determine the snapshot with name "ANMImage-image_os_disk_snapshot-eastus2" already exist?

If so, this is because a new target storage account will be created for copying the snapshot to the target region every time when the target image is created, which will cause the target blob path to be different from the previous one, resulting in the change of sourceUri. However, at present, the service does not support modifying the sourceUri of an existing disk, so this problem occurs.

kgfly commented 3 years ago

@zhoxing-ms , just double checked. "ANMImage-image_os_disk_snapshot-eastus2" does not exist. I only have " ANMImage-image_os_disk_snapshot"

zhoxing-ms commented 3 years ago

Because this is an error returned by the REST, so we need the service team to see why this error is returned

zhoxing-ms commented 3 years ago

@grizzlytheodore Could you please help look at the cause of error Output: Changing property 'sourceUri' is not allowed for existing disk 'YYY-image_os_disk_snapshot-eastus'.