Skip to content

az vm create: SkuNotAvailable throws RuntimeError instead of clear error message #33159

@techsaurabh-394

Description

@techsaurabh-394

Bug Report

Description

When running az vm create with a VM size that is unavailable due to capacity restrictions, the CLI throws a confusing RuntimeError: The content for this response was already consumed instead of showing a clear, actionable error message.

The actual root cause (SkuNotAvailable) is buried deep in the traceback and not surfaced cleanly to the user.


Command Used

az vm create \
  -g rg-openclaw -n vm-openclaw \
  --image Ubuntu2204 \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys \
  --vnet-name vnet-openclaw \
  --subnet snet-openclaw-vm \
  --location eastus

Expected Behavior

A clean, user-friendly error message like:

ERROR: The VM size 'Standard_B2s' is not available in location 'eastus' due to capacity restrictions.
Suggestion: Try a different size or region. Run `az vm list-skus` to find available sizes.

Actual Behavior

RuntimeError: The content for this response was already consumed

The real cause (SkuNotAvailable: Standard_B2s not available in eastus/eastus2) is only visible deep in the traceback.


Impact

  • Confusing for new Azure users
  • No actionable suggestion is shown
  • User has to read the full traceback to understand the real problem

Environment

  • Azure CLI version: latest (Azure Cloud Shell)
  • OS: Linux (Azure Cloud Shell)
  • Locations tested: eastus, eastus2
  • VM size: Standard_B2s

Suggested Fix

In arm.py, catch SkuNotAvailable inner exceptions and surface them as a clean CLIError with a helpful suggestion to run az vm list-skus.


References

Related command

az vm create

Errors

(InvalidTemplateDeployment) The template deployment is not valid according to the validation procedure.
Code: InvalidTemplateDeployment

Inner Error:
Code: SkuNotAvailable
Message: The requested VM size for resource 'Following SKUs have failed for Capacity
Restrictions: Standard_B2s' is currently not available in location 'eastus'.
Please try another size or deploy to a different location or different zone.

RuntimeError: The content for this response was already consumed

Issue script & Debug output

az vm create
-g rg-openclaw -n vm-openclaw
--image Ubuntu2204
--size Standard_B2s
--admin-username azureuser
--generate-ssh-keys
--vnet-name vnet-openclaw
--subnet snet-openclaw-vm
--debug

Expected behavior

ERROR: The VM size 'Standard_B2s' is not available in location 'eastus'
due to capacity restrictions. Try a different size or region.
Tip: Run az vm list-skus --location eastus --size Standard_B --output table
to find available sizes.

Environment Summary

az --version

Additional context

Tested in both eastus and eastus2 — Standard_B2s unavailable in both
Error occurs in arm.py inside handle_template_based_exception where ex.inner_exception is None, causing an AttributeError that masks the real SkuNotAvailable error
Suggested fix: in arm.py, explicitly catch SkuNotAvailable from inner exceptions and raise a clean CLIError with a helpful suggestion
Reference: https://aka.ms/azureskunotavailable

Metadata

Metadata

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamComputeaz vm/vmss/image/disk/snapshotError MessagesPossible-SolutionSimilar-Issueact-observability-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions