Skip to content

[Compute] Normalize storage type case in target region validation - #33882

Open
Hashim Khan (Hashim1999164) wants to merge 1 commit into
Azure:devfrom
Hashim1999164:fix/target-regions-storage-type-case-33880
Open

[Compute] Normalize storage type case in target region validation#33882
Hashim Khan (Hashim1999164) wants to merge 1 commit into
Azure:devfrom
Hashim1999164:fix/target-regions-storage-type-case-33880

Conversation

@Hashim1999164

@Hashim1999164 Hashim Khan (Hashim1999164) commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

az sig image-version create --target-regions validated storage account types case-insensitively for the two-part form (region=Standard_LRS) but case-sensitively for the three-part form (region=1=Standard_LRS).

This compares with .lower() in the three-part path, matching the two-part path, and applies the same fix to the four-part --target-edge-zones validator. A unit test covers mixed-case three-part and two-part values.

Fixes #33880

Test plan

  1. python -m unittest azure.cli.command_modules.vm.tests.latest.test_vm_actions.TestVMImage.test_process_gallery_image_version_namespace (or the local test module equivalent)
  2. Confirm southeastasia=1=Standard_LRS no longer fails local 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 Azure#33880.
@Hashim1999164
Hashim Khan (Hashim1999164) requested a review from a team as a code owner August 12, 2026 23:40
Copilot AI lite review requested due to automatic review settings August 12, 2026 23:40
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Aug 12, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Hashim Khan (@Hashim1999164)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes inconsistent case handling for storage account type validation in az sig image-version create parsing logic, making mixed-case values behave consistently across supported --target-regions/--target-edge-zones syntaxes.

Changes:

  • Make three-part --target-regions parsing validate storage account types case-insensitively (matching the existing two-part behavior).
  • Apply the same case-insensitive validation to four-part --target-edge-zones parsing.
  • Add a unit test covering mixed-case --target-regions values (two-part and three-part).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_actions.py Adds test coverage for mixed-case storage types in --target-regions parsing.
src/azure-cli/azure/cli/command_modules/vm/_validators.py Updates validators to check storage_account_type.lower() for three-part target regions and four-part target edge zones.
Suppressed comments (1)

src/azure-cli/azure/cli/command_modules/vm/_validators.py:2506

  • Typo in error message: "forth" should be "fourth".
                    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. "
                            "Storage account types must be one of {}.".format(t, storage_account_types_str))

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +586 to +597
# 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")

@yonzhan

Copy link
Copy Markdown
Collaborator

Compute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-codegen-extensibility-squad act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage az storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compute] --target-regions storage type validation is case-sensitive only in three-part syntax

4 participants