From 3fc353a078ffdac47642147e9314a1d0d23a31f1 Mon Sep 17 00:00:00 2001 From: Hashim Khan <64767361+Hashim1999164@users.noreply.github.com> Date: Thu, 13 Aug 2026 04:40:03 +0500 Subject: [PATCH] Normalize storage type case in target region validation Compare three-part --target-regions storage account types with .lower(), matching the two-part form. Apply the same check to four-part --target-edge-zones validation. Fixes #33880. --- .../azure/cli/command_modules/vm/_validators.py | 4 ++-- .../vm/tests/latest/test_vm_actions.py | 12 ++++++++++++ 2 files changed, 14 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 8182ca2334c..1a664444905 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -2366,7 +2366,7 @@ def process_gallery_image_version_namespace(cmd, namespace): try: replica_count = int(parts[1]) # raises ValueError if this is not a replica count, try other order. storage_account_type = parts[2] - if storage_account_type not in storage_account_types_list: + if storage_account_type.lower() not in storage_account_types_list: raise ArgumentUsageError( "usage error: {} is an invalid target region argument. " "The third part is not a valid storage account type. " @@ -2499,7 +2499,7 @@ def process_gallery_image_version_namespace(cmd, namespace): try: replica_count = int(parts[2]) # raises ValueError if this is not a replica count, try other order. storage_account_type = parts[3] - if storage_account_type not in storage_account_types_list: + if storage_account_type.lower() not in storage_account_types_list: raise ArgumentUsageError( "usage error: {} is an invalid target edge zone argument. " "The forth part is not a valid storage account type. " diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_actions.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_actions.py index 23041bf3300..13224d633e9 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_actions.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_actions.py @@ -583,6 +583,18 @@ def test_process_gallery_image_version_namespace(self): self.assertEqual(target_regions_objs[3]["regional_replica_count"], 2) self.assertEqual(target_regions_objs[3]["storage_account_type"], "standard_lrs") + # three-part region=replica=storage_type must accept mixed-case storage types + # the same way the two-part region=storage_type form does + target_regions_list = ["southeastasia=1=Standard_LRS", "westus2=Premium_LRS"] + np.target_regions = target_regions_list + process_gallery_image_version_namespace(cmd, np) + target_regions_objs = np.target_regions + self.assertEqual(target_regions_objs[0]["name"], "southeastasia") + self.assertEqual(target_regions_objs[0]["regional_replica_count"], 1) + self.assertEqual(target_regions_objs[0]["storage_account_type"], "Standard_LRS") + self.assertEqual(target_regions_objs[1]["name"], "westus2") + self.assertEqual(target_regions_objs[1]["storage_account_type"], "Premium_LRS") + # handle invalid storage account / replica count with self.assertRaises(CLIError): target_regions_list = ["westus=f"]