From 10472a22e816af45773d16ce3db3ed524e34aff5 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 11 Jun 2026 09:04:15 +0800 Subject: [PATCH 1/4] Migrated function that uses _get_disk_or_snapshot_info --- .../cli/command_modules/vm/_validators.py | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/_validators.py index 6a8b0de98e4..e87923cea90 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -2147,7 +2147,7 @@ def process_snapshot_create_namespace(cmd, namespace): from azure.cli.core.util import parse_proxy_resource_id result = parse_proxy_resource_id(namespace.source_disk or namespace.source_snapshot) try: - source_info, _ = _get_disk_or_snapshot_info(cmd.cli_ctx, + source_info, _ = _get_disk_or_snapshot_info_by_aaz(cmd.cli_ctx, result['resource_group'], result['name']) except Exception: # pylint: disable=broad-except @@ -2161,7 +2161,7 @@ def process_snapshot_create_namespace(cmd, namespace): get_default_location_from_resource_group(cmd, namespace) # if the source location differs from target location, then it's copy_start scenario if namespace.incremental: - namespace.copy_start = source_info.location != namespace.location + namespace.copy_start = source_info.get('location') != namespace.location except HttpResponseError: raise ArgumentUsageError(usage_error) @@ -2231,11 +2231,11 @@ def _figure_out_storage_source(cli_ctx, resource_group_name, source): elif '/restorepoints/' in source.lower(): source_restore_point = source else: - source_info, is_snapshot = _get_disk_or_snapshot_info(cli_ctx, resource_group_name, source) + source_info, is_snapshot = _get_disk_or_snapshot_info_by_aaz(cli_ctx, resource_group_name, source) if is_snapshot: - source_snapshot = source_info.id + source_snapshot = source_info.get('id') else: - source_disk = source_info.id + source_disk = source_info.get('id') return (source_blob_uri, source_disk, source_snapshot, source_restore_point, source_info) @@ -2264,19 +2264,6 @@ def _figure_out_storage_source_by_aaz(cli_ctx, resource_group_name, source): return (source_blob_uri, source_disk, source_snapshot, source_restore_point, source_info) -def _get_disk_or_snapshot_info(cli_ctx, resource_group_name, source): - compute_client = _compute_client_factory(cli_ctx) - is_snapshot = True - - try: - info = compute_client.snapshots.get(resource_group_name, source) - except ResourceNotFoundError: - is_snapshot = False - info = compute_client.disks.get(resource_group_name, source) - - return info, is_snapshot - - def _get_disk_or_snapshot_info_by_aaz(cli_ctx, resource_group_name, source): from .aaz.latest.snapshot import Show as SnapshotShow from .aaz.latest.disk import Show as DiskShow From 3c38727fb5d558231ee022b20f4330b4c1dda0dd Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 11 Jun 2026 09:43:33 +0800 Subject: [PATCH 2/4] update code style --- src/azure-cli/azure/cli/command_modules/vm/_validators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/_validators.py index e87923cea90..aa6ddeb5280 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -2148,8 +2148,8 @@ def process_snapshot_create_namespace(cmd, namespace): result = parse_proxy_resource_id(namespace.source_disk or namespace.source_snapshot) try: source_info, _ = _get_disk_or_snapshot_info_by_aaz(cmd.cli_ctx, - result['resource_group'], - result['name']) + result['resource_group'], + result['name']) except Exception: # pylint: disable=broad-except # There's a chance that the source doesn't exist, eg, vmss os disk. # You can get the id of vmss os disk by From 7593b7a349836bed26fcc07a9f7f0c77c9505fa8 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 11 Jun 2026 12:50:11 +0800 Subject: [PATCH 3/4] Update test case recording --- .../latest/recordings/test_completion_percent.yaml | 4 ++-- ...image_version_with_region_cvm_encryption_pmk.yaml | 4 ++-- ..._snapshot_hyper_v_generation_default_to_null.yaml | 4 ++-- .../recordings/test_gallery_image_version_vhd.yaml | 8 ++++---- .../latest/recordings/test_gallery_specialized.yaml | 12 ++++++------ .../latest/recordings/test_snapshot_incremental.yaml | 6 +++--- .../latest/recordings/test_snapshot_ultra_ssd.yaml | 4 ++-- ..._vm_data_disk_creation_from_copy_and_restore.yaml | 4 ++-- .../test_vm_disk_create_with_standard_zrs_sku.yaml | 4 ++-- .../recordings/test_vm_disk_max_shares_etc.yaml | 4 ++-- .../latest/recordings/test_vm_managed_disk.yaml | 4 ++-- .../test_vm_snapshot_copy_start_detection.yaml | 8 ++++---- .../test_vm_snapshot_enable_instant_access.yaml | 4 ++-- .../recordings/test_vm_snapshot_incremental.yaml | 4 ++-- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_completion_percent.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_completion_percent.yaml index 60d92282ca7..4be0f50749b 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_completion_percent.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_completion_percent.yaml @@ -195,7 +195,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/disk1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/disk1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk1'' @@ -243,7 +243,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk1\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_create_image_version_with_region_cvm_encryption_pmk.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_create_image_version_with_region_cvm_encryption_pmk.yaml index 4fab5f5a833..be3e917c386 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_create_image_version_with_region_cvm_encryption_pmk.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_create_image_version_with_region_cvm_encryption_pmk.yaml @@ -810,7 +810,7 @@ interactions: User-Agent: - AZURECLI/2.77.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/snapshots/disk000003?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/snapshots/disk000003?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk000003'' @@ -858,7 +858,7 @@ interactions: User-Agent: - AZURECLI/2.77.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/disks/disk000003?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/disks/disk000003?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/disks/disk000003\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_snapshot_hyper_v_generation_default_to_null.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_snapshot_hyper_v_generation_default_to_null.yaml index c84ecb52f03..34d17ad4b12 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_snapshot_hyper_v_generation_default_to_null.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_snapshot_hyper_v_generation_default_to_null.yaml @@ -241,7 +241,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_disk_snapshot_hyper_v_generation_default_to_null000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_disk_snapshot_hyper_v_generation_default_to_null000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk000002'' @@ -289,7 +289,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_disk_snapshot_hyper_v_generation_default_to_null000001/providers/Microsoft.Compute/disks/disk000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_disk_snapshot_hyper_v_generation_default_to_null000001/providers/Microsoft.Compute/disks/disk000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_disk_snapshot_hyper_v_generation_default_to_null000001/providers/Microsoft.Compute/disks/disk000002\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_image_version_vhd.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_image_version_vhd.yaml index 9bbc4467657..9da2e202b1a 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_image_version_vhd.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_image_version_vhd.yaml @@ -5367,7 +5367,7 @@ interactions: User-Agent: - AZURECLI/2.80.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/snapshots/d1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/snapshots/d1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d1'' @@ -5415,7 +5415,7 @@ interactions: User-Agent: - AZURECLI/2.80.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d1\",\r\n @@ -5741,7 +5741,7 @@ interactions: User-Agent: - AZURECLI/2.80.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/snapshots/d2?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/snapshots/d2?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d2'' @@ -5789,7 +5789,7 @@ interactions: User-Agent: - AZURECLI/2.80.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d2?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d2?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d2\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_image_version_vhd000001/providers/Microsoft.Compute/disks/d2\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_specialized.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_specialized.yaml index 9f751f58a07..f74c8d476f8 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_specialized.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_gallery_specialized.yaml @@ -1119,7 +1119,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d1'' @@ -1167,7 +1167,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d1\",\r\n @@ -1453,7 +1453,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d2?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d2?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d2'' @@ -1497,7 +1497,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d2?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d2?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d2\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d2\",\r\n @@ -1776,7 +1776,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d3?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/snapshots/d3?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d3'' @@ -1820,7 +1820,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d3?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d3?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d3\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_gallery_specialized_000001/providers/Microsoft.Compute/disks/d3\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_incremental.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_incremental.yaml index 3e5ddb7b021..0be6df24d04 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_incremental.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_incremental.yaml @@ -241,7 +241,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk000002'' @@ -289,7 +289,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/disks/disk000002\",\r\n @@ -578,7 +578,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/snap000003?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/snap000003?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"snap000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_completion_percent1_000001/providers/Microsoft.Compute/snapshots/snap000003\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_ultra_ssd.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_ultra_ssd.yaml index 42ed8e95c6f..2c25e01639d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_ultra_ssd.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_snapshot_ultra_ssd.yaml @@ -242,7 +242,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_snapshot_ultra_ssd000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_snapshot_ultra_ssd000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk000002'' @@ -290,7 +290,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_snapshot_ultra_ssd000001/providers/Microsoft.Compute/disks/disk000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_snapshot_ultra_ssd000001/providers/Microsoft.Compute/disks/disk000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_snapshot_ultra_ssd000001/providers/Microsoft.Compute/disks/disk000002\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_data_disk_creation_from_copy_and_restore.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_data_disk_creation_from_copy_and_restore.yaml index dbd582c63c9..2904834253a 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_data_disk_creation_from_copy_and_restore.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_data_disk_creation_from_copy_and_restore.yaml @@ -5758,7 +5758,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_data_disk_creation_from_copy_and_restore000001/providers/Microsoft.Compute/snapshots/disk_000008?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_data_disk_creation_from_copy_and_restore000001/providers/Microsoft.Compute/snapshots/disk_000008?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk_000008'' @@ -5806,7 +5806,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_data_disk_creation_from_copy_and_restore000001/providers/Microsoft.Compute/disks/disk_000008?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_data_disk_creation_from_copy_and_restore000001/providers/Microsoft.Compute/disks/disk_000008?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk_000008\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_data_disk_creation_from_copy_and_restore000001/providers/Microsoft.Compute/disks/disk_000008\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_create_with_standard_zrs_sku.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_create_with_standard_zrs_sku.yaml index 7372e5da400..0d165f4b659 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_create_with_standard_zrs_sku.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_create_with_standard_zrs_sku.yaml @@ -241,7 +241,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-std_zrs000001/providers/Microsoft.Compute/snapshots/d1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-std_zrs000001/providers/Microsoft.Compute/snapshots/d1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d1'' @@ -289,7 +289,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-std_zrs000001/providers/Microsoft.Compute/disks/d1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-std_zrs000001/providers/Microsoft.Compute/disks/d1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-std_zrs000001/providers/Microsoft.Compute/disks/d1\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_max_shares_etc.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_max_shares_etc.yaml index 95055a86724..f7afe7b3aba 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_max_shares_etc.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_disk_max_shares_etc.yaml @@ -1810,7 +1810,7 @@ interactions: User-Agent: - AZURECLI/2.81.0 azsdk-python-core/1.37.0 Python/3.12.10 (Windows-11-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_disk_max_shares_etc_000001/providers/Microsoft.Compute/snapshots/disk?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_disk_max_shares_etc_000001/providers/Microsoft.Compute/snapshots/disk?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk'' @@ -1858,7 +1858,7 @@ interactions: User-Agent: - AZURECLI/2.81.0 azsdk-python-core/1.37.0 Python/3.12.10 (Windows-11-10.0.26200-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_disk_max_shares_etc_000001/providers/Microsoft.Compute/disks/disk?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_disk_max_shares_etc_000001/providers/Microsoft.Compute/disks/disk?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_disk_max_shares_etc_000001/providers/Microsoft.Compute/disks/disk\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_managed_disk.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_managed_disk.yaml index 605e6a46853..df1f684a664 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_managed_disk.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_managed_disk.yaml @@ -1405,7 +1405,7 @@ interactions: User-Agent: - AZURECLI/2.77.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_managed_disk000001/providers/Microsoft.Compute/snapshots/d1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_managed_disk000001/providers/Microsoft.Compute/snapshots/d1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d1'' @@ -1453,7 +1453,7 @@ interactions: User-Agent: - AZURECLI/2.77.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_managed_disk000001/providers/Microsoft.Compute/disks/d1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_managed_disk000001/providers/Microsoft.Compute/disks/d1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_managed_disk000001/providers/Microsoft.Compute/disks/d1\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_copy_start_detection.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_copy_start_detection.yaml index 56301692b18..821e82a784c 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_copy_start_detection.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_copy_start_detection.yaml @@ -195,7 +195,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/snapshots/testdisk-000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/snapshots/testdisk-000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/testdisk-000002'' @@ -243,7 +243,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"testdisk-000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002\",\r\n @@ -530,7 +530,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/snapshots/testdisk-000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/snapshots/testdisk-000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/testdisk-000002'' @@ -578,7 +578,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"testdisk-000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_copy_start_000001/providers/Microsoft.Compute/disks/testdisk-000002\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_enable_instant_access.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_enable_instant_access.yaml index 62f6643a240..e1ec5a78e7a 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_enable_instant_access.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_enable_instant_access.yaml @@ -243,7 +243,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_enable_instant_access000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_enable_instant_access000001/providers/Microsoft.Compute/snapshots/disk000002?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/disk000002'' @@ -291,7 +291,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_enable_instant_access000001/providers/Microsoft.Compute/disks/disk000002?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_enable_instant_access000001/providers/Microsoft.Compute/disks/disk000002?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"disk000002\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_enable_instant_access000001/providers/Microsoft.Compute/disks/disk000002\",\r\n diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_incremental.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_incremental.yaml index 96f00ba838c..15de920cfb9 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_incremental.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_snapshot_incremental.yaml @@ -195,7 +195,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_incremental_000001/providers/Microsoft.Compute/snapshots/d1?api-version=2023-10-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_incremental_000001/providers/Microsoft.Compute/snapshots/d1?api-version=2025-01-02 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Compute/snapshots/d1'' @@ -243,7 +243,7 @@ interactions: User-Agent: - AZURECLI/2.76.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_incremental_000001/providers/Microsoft.Compute/disks/d1?api-version=2023-04-02 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_incremental_000001/providers/Microsoft.Compute/disks/d1?api-version=2025-01-02 response: body: string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_snapshot_incremental_000001/providers/Microsoft.Compute/disks/d1\",\r\n From 3961ff1b153839636a33795e37f96c4d567994cd Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 11 Jun 2026 13:24:31 +0800 Subject: [PATCH 4/4] Remove unused import --- src/azure-cli/azure/cli/command_modules/vm/_validators.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/_validators.py index aa6ddeb5280..ce42a259f4b 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -23,7 +23,6 @@ from azure.cli.core import keys from azure.core.exceptions import ResourceNotFoundError -from ._client_factory import _compute_client_factory from ._actions import _get_latest_image_version_by_aaz