Repository navigation
{Compute} az vm/vmss create: Allow to use --os-type for when gallery image definition access is denied - #34307
William (william051200) wants to merge 6 commits into
Conversation
|
William (@william051200) The newly reachable specialized Windows fallback still rejects creation without credentials. Upstream CI passed, but regression coverage for the real authorization scenario is not verified. To addressTick each item as you address it.
Review detailsUpstream CIThe handoff reports 52/52 upstream checks passed. Test validation
Risk assessment37/100 · Medium The Medium rating is driven by public CLI behavior, failure-handling behavior.
Ask the Agent Tick a box to queue an action. Requires write access to this repository.
|
There was a problem hiding this comment.
🟡 Changes recommended
The added scenario only exercises a 403 response, leaving successful definition reads untested for case-insensitive OS-type matches and mismatches that should raise InvalidArgumentValueError.
1 open issue
What changed in this PR
This PR addresses #16674 by allowing az vm create and az vmss create to use an explicit OS type when gallery image-definition access is denied, while preserving automatic detection when access is available.
Changes:
- Accepts
--os-typefor gallery images and validates it against readable definitions. - Provides guidance when access is denied and
--os-typeis missing. - Adds a VMSS regression scenario and recording for the denied-access fallback.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py |
Tests missing and explicit OS types with a simulated definition-read denial. |
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_create_gallery_image_without_definition_read.yaml |
Records resource setup and successful VMSS creation for playback. |
src/azure-cli/azure/cli/command_modules/vm/_validators.py |
Adds the access-denied fallback and OS-type consistency validation. |
src/azure-cli/azure/cli/command_modules/vm/_params.py |
Documents gallery-image support in --os-type help. |
Review effort: Balanced
| if namespace.os_type and namespace.os_type.lower() != image_info.get('osType', '').lower(): | ||
| raise InvalidArgumentValueError( | ||
| "The specified --os-type '{}' does not match the gallery image OS type '{}'." | ||
| .format(namespace.os_type, image_info.get('osType'))) |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
@Azure/x-engineering-agent I have fixed the failure, run again |
There was a problem hiding this comment.
Review comments are inline on the changed lines. See the X Engineering Agent Report.
| namespace.os_type = image_info.get('osType') | ||
| try: | ||
| image_info = SigImageDefinitionShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) | ||
| except HttpResponseError as ex: |
There was a problem hiding this comment.
Specialized fallback still requires credentials
The newly admitted 403 fallback reaches authentication for specialized Windows gallery images. Without credentials, VM and both VMSS modes fail at _validators.py:1335, although specialized templates omit osProfile. Skip authentication provisioning for specialized gallery images and verify all three creation modes without credentials, preserving generalized-image authentication.
X Engineering Agent · Reviewer · React with +1 or -1 to train the reviewer

🤖 PR Validation — ️✔️ All clear
Related command
az vm/vmss createDescription
Resolve #16674
Allow
az vm createandaz vmss createto use--os-typewhen permission to read the gallery image definition is denied. Keep automatic OS detection when access is available, and prompt for--os-typewhen needed.Testing Guide
azdev test test_vmss_create_gallery_image_without_definition_read --liveHistory Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.