Skip to content

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

Description

@linxinkenvie

Describe the bug

az sig image-version create validates the storage account type in --target-regions inconsistently depending on which supported argument form is used:

  • southeastasia=Standard_LRS (region + storage type) passes local validation.
  • southeastasia=1=Standard_LRS (region + replica count + storage type) fails local validation.
  • southeastasia=1=standard_lrs passes local validation.

This reproduces on the latest released Azure CLI 2.89.1 using the official MCR image and a blank Azure config directory. No login or Azure resources are required.

The validator appears to normalize case in the two-part branch but not in the three-part branch. In _validators.py for 2.89.1, the two-part branch checks parts[1].lower() while the three-part branch checks storage_account_type directly.

Related command

podman run --rm \
  -e AZURE_CONFIG_DIR=/tmp/azcfg \
  mcr.microsoft.com/azure-cli:2.89.1 \
  az sig image-version create \
  --resource-group rg-demo \
  --gallery-name gallery-demo \
  --gallery-image-definition image-demo \
  --gallery-image-version 1.0.0 \
  --managed-image /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-demo/providers/Microsoft.Compute/images/source-demo \
  --no-wait \
  --target-regions southeastasia=1=Standard_LRS \
  --debug

(docker run can be used instead of podman run.)

Errors

ERROR: usage error: southeastasia=1=Standard_LRS is an invalid target region argument. The third part is not a valid storage account type. Storage account types must be one of standard_lrs, standard_zrs, premium_lrs.

Issue script & Debug output

The failing command above uses only dummy resource identifiers and a blank config directory. Relevant debug output:

DEBUG: cli.azure.cli.core: Raw command  : sig image-version create
DEBUG: cli.azure.cli.core: Command table: sig image-version create
...
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/vm/_validators.py", line 2587, in process_image_version_create_namespace
  process_gallery_image_version_namespace(cmd, namespace)
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/command_modules/vm/_validators.py", line 2370, in process_gallery_image_version_namespace
  raise ArgumentUsageError(
azure.cli.core.azclierror.ArgumentUsageError: usage error: southeastasia=1=Standard_LRS is an invalid target region argument. The third part is not a valid storage account type. Storage account types must be one of standard_lrs, standard_zrs, premium_lrs.
INFO: az_command_data_logger: exit code: 1

Two zero-login controls demonstrate the inconsistent parser behavior:

--target-regions southeastasia=1=standard_lrs
ERROR: Please run 'az login' to setup account.

--target-regions southeastasia=Standard_LRS
ERROR: Please run 'az login' to setup account.

Both controls reach authentication, while the three-part mixed-case form is rejected earlier by local argument validation.

Expected behavior

The storage account type should be handled consistently across both supported --target-regions forms. Preferably, the three-part form should perform the same case-insensitive validation as the two-part form and normalize the value before constructing the request.

Environment Summary

Official container: mcr.microsoft.com/azure-cli:2.89.1

azure-cli                         2.89.1
core                              2.89.1
telemetry                          1.1.0

Dependencies:
msal                              1.36.0
azure-mgmt-resource               24.0.0

Python location '/usr/bin/python3.12'
Python (Linux) 3.12.9

The same failure was also observed with Azure CLI 2.88.0.

Additional context

This can have a disproportionate impact on automated image pipelines because the final Gallery image-version create may happen only after guest preparation, Sysprep, deallocation, and generalization. In our case the command failed locally before any Gallery image-version write was sent, after the billable builder work had already completed.

I searched open and closed issues for the exact diagnostic, target-regions, and Standard_LRS and did not find an existing report for this branch inconsistency.

Metadata

Metadata

Labels

Accountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamComputeaz vm/vmss/image/disk/snapshotact-identity-squadact-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions