Skip to content

{vm-repair} Migrate commands calling Compute module to aaz-based implementation and add handling for extension version is null case#10106

Open
william051200 wants to merge 6 commits into
Azure:mainfrom
william051200:vm-repair-migration
Open

{vm-repair} Migrate commands calling Compute module to aaz-based implementation and add handling for extension version is null case#10106
william051200 wants to merge 6 commits into
Azure:mainfrom
william051200:vm-repair-migration

Conversation

@william051200

@william051200 william051200 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Migrate code from Azure SDK to AAZ based commands for compute operations
Replace deprecated pkgutil loader with importlib.import_module

After running some tests for version compatibility, here are the results I got,
az extension add vm-repair 2.2.1 package generated from azdev 0.2.12 & 0.2.13 will show version = null

Those successfully installed (with no null version) also runs properly, with no error.
This confirms the migration has no issue & the issue raised by user is caused by version incompatibility.

Azure CLI 0.87:
1. azdev 0.2.13 - fail (no version)
2. azdev 0.2.12 - fail (no version)
3. azdev 0.2.10 - success
4. azdev 0.2.9 - success
5. azdev 0.2.8 - success

Azure CLI 0.88:
1. azdev 0.2.13 - success
2. azdev 0.2.12 - success
3. azdev 0.2.10 - success
4. azdev 0.2.9 - success
5. azdev 0.2.8 - success

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

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copilot AI review requested due to automatic review settings July 14, 2026 03:06
@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Jul 14, 2026

Copy link
Copy Markdown
️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

Copilot AI left a comment

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.

Pull request overview

This PR updates the vm-repair extension to use AAZ-based VM retrieval helpers (instead of Compute SDK objects) and adds defensive handling in extension-version checking to avoid crashes when version metadata is missing.

Changes:

  • Bump vm-repair extension version to 2.2.1 and update release notes.
  • Migrate VM object access patterns across custom.py, _validators.py, and repair_utils.py from SDK object attributes to AAZ JSON/dict access.
  • Add handling in check_extension_version to avoid 'str' > 'NoneType' crashes when extension version is null.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vm-repair/setup.py Version bump to 2.2.1.
src/vm-repair/HISTORY.rst Add 2.2.1 release notes describing the migration and crash fix.
src/vm-repair/azext_vm_repair/repair_utils.py Switch VM parsing to dict access; add null-safe extension version check.
src/vm-repair/azext_vm_repair/custom.py Switch command implementation to AAZ VM retrieval and dict-based VM field access.
src/vm-repair/azext_vm_repair/_validators.py Switch validation logic to AAZ VM retrieval and dict-based access.

Comment on lines +510 to 512
os_image_ref = source_vm.get('storageProfile', {}).get('imageReference', {})
if os_image_ref and os_image_ref.get('version') in urns[0]:
if len(urns) < 2:
Comment on lines +522 to +526
repair_vm = get_vm_by_aaz(cmd, repair_vm_id['resource_group'], repair_vm_id['name'])
data_disks = repair_vm.get('storageProfile', {}).get('dataDisks')

# The params went through validator so no need for existence checks
disk_uri = [disk.vhd.uri for disk in data_disks if disk.name == disk_name][0]
disk_uri = [disk.get('vhd', {}).get('uri') for disk in data_disks if disk.get('name') == disk_name][0]
@yonzhan

yonzhan commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

vm-repair

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants