{Compute} Fix ModuleNotFoundError by removing unnecessary gallery_image_versions#33150
{Compute} Fix ModuleNotFoundError by removing unnecessary gallery_image_versions#33150JaysonTaiMicrosoft wants to merge 5 commits intoAzure:devfrom
Conversation
️✔️AzureCLI-FullTest
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| sig image-version create | cmd sig image-version create update parameter replication_mode: added property choices=['Full', 'Shallow'] |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Pull request overview
This PR removes remaining non-AAZ references to the gallery_image_versions Compute SDK operation group from the VM command module, resolving ModuleNotFoundError triggered during command table/argument loading (e.g., az vm list --debug).
Changes:
- Removed the
GalleryImageVersionsOperations-based command type and command group wiring forsig image-version. - Removed
gallery_image_versions-scoped model/argument context usage and replaced theReplicationModemodel enum with an explicit enum list. - Dropped the
gallery_image_versionsAPI-version entry from the core compute SDK profile mapping and removed the unused VM client factory for it.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/custom.py |
Simplifies create_image_version by removing API-version branching tied to gallery_image_versions. |
src/azure-cli/azure/cli/command_modules/vm/commands.py |
Removes SDK command type and operation-group binding for sig image-version to avoid importing missing SDK ops. |
src/azure-cli/azure/cli/command_modules/vm/_params.py |
Removes gallery_image_versions model lookup/context and hardcodes replication_mode enum values. |
src/azure-cli/azure/cli/command_modules/vm/_client_factory.py |
Deletes the unused cf_gallery_image_versions client factory. |
src/azure-cli-core/azure/cli/core/profiles/_shared.py |
Removes gallery_image_versions from the compute SDK profile operation-group version map. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| source = {"managed_image": {"id": managed_image}} | ||
| profile["source"] = source | ||
|
|
||
| if managed_image is None and os_snapshot is None and os_vhd_uri is None: | ||
| raise RequiredArgumentMissingError('usage error: Please provide --managed-image or --os-snapshot or --vhd') | ||
|
|
||
| source = os_disk_image = data_disk_images = None |
There was a problem hiding this comment.
In create_image_version, profile["source"] is now set unconditionally using the legacy {managed_image: {id: ...}} shape, but the actual request source is built later via storage_profile["source"] (using {id: ...} / {virtual_machine_id: ...}). Since the AAZ sig image-version create schema doesn’t have a publishing_profile.source field, this assignment is ignored and the source variable name is then re-used for a different payload shape, making the flow harder to follow. Consider removing the profile["source"] assignment and using a distinct variable name for the storage_profile source to avoid shadowing.
…nTaiMicrosoft/azure-cli into fix-module-not-found-error
|
@microsoft-github-policy-service agree company="Microsoft" |
| if not cmd.supported_api_version(min_api='2022-03-03', operation_group='gallery_image_versions'): | ||
| source = {"managed_image": {"id": managed_image}} | ||
| profile["source"] = source |
There was a problem hiding this comment.
This if statement checks whether the API version is earlier than 2022-03-03, and executes the code if it is.
I think we can safely remove these lines.
There was a problem hiding this comment.
Yes I agree, I have removed it now.
Related command
az vm list --debugDescription
Remove unnecessary references to

gallery_image_versionsfor already AAZ migratedsig image versioncommands causingModuleNotFounderrorsTesting Guide
Run
az vm list --debugthere should no longer be aModuleNotFoundErrorHistory 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.