Azure / Azure/azure-cli-extensions
az copy image between subscriptions: snapshot using target subscription instead of source subscription
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
### Related command
az image copy --source-resource-group "RGP-SOURCE" --source-object-name "vm_6.11.0_fixed" --target-location "eastus" --target-resource-group "RGP-DEST" --target-subscription "XXXX-XXXXXXXX-XXXX" --target-name="vm_6.11.0" --cleanup --debug
### Extension name (the extension in question)
az extension update --name image-copy-extension --debug
cli.azure.cli.core.extension._resolve: Skipping 'image_copy_extension-0.2.12-py2.py3-none-any.whl' as 0.2.12 not greater than current version 0.2.12
cli.azure.cli.core.extension.operations: Latest version of 'image-copy-extension' is already installed.
### Description of issue (in as much detail as possible)
I set the subscription via
az account set --subscription "SOURCE_SUBSCRIPTION_ID"
There is no --source-subscription flag anymore so it should be getting the source from the RGP name / id
I applied my own fix for now in .azure/cliextensions/image-copy-extension/azext_imagecopy/custom.py
I added:
(quick fix to get source subscription)
line 55
source_subscription=json_cmd_output['id'].split('/')[2]
logger.warning('source_subscription: %s', source_subscription)
I changed this function to use the source RGP ID for the snapshot:
Original:
if source_os_disk_type == "BLOB":
source_storage_account_id = get_storage_account_id_from_blob_path(source_os_disk_id,
source_resource_group_name,
target_subscription)
Replaced:
if source_os_disk_type == "BLOB":
source_storage_account_id = get_storage_account_id_from_blob_path(source_os_disk_id,
source_resource_group_name,
**source_subscription**)
-----
Contributor guide
Assessment
This issue has not been assessed yet.