Skip to content

{Compute} Fix ModuleNotFoundError by removing unnecessary gallery_image_versions#33150

Open
JaysonTaiMicrosoft wants to merge 5 commits intoAzure:devfrom
JaysonTaiMicrosoft:fix-module-not-found-error
Open

{Compute} Fix ModuleNotFoundError by removing unnecessary gallery_image_versions#33150
JaysonTaiMicrosoft wants to merge 5 commits intoAzure:devfrom
JaysonTaiMicrosoft:fix-module-not-found-error

Conversation

@JaysonTaiMicrosoft
Copy link
Copy Markdown

Related command
az vm list --debug

Description

Remove unnecessary references to gallery_image_versions for already AAZ migrated sig image version commands causing ModuleNotFound errors
image

Testing Guide

Run az vm list --debug there should no longer be a ModuleNotFoundError

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

@JaysonTaiMicrosoft JaysonTaiMicrosoft self-assigned this Apr 8, 2026
Copilot AI review requested due to automatic review settings April 8, 2026 07:20
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 8, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 8, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1008 - ParaPropAdd sig image-version create cmd sig image-version create update parameter replication_mode: added property choices=['Full', 'Shallow']

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 8, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 for sig image-version.
  • Removed gallery_image_versions-scoped model/argument context usage and replaced the ReplicationMode model enum with an explicit enum list.
  • Dropped the gallery_image_versions API-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.

Comment on lines +5683 to +5689
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
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@JaysonTaiMicrosoft
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Comment on lines -5683 to -5685
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
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.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes I agree, I have removed it now.

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

Labels

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModuleNotFoundError on vm commands when using --debug flag

5 participants