[image-gallery] Migrate commands calling Compute module to aaz-based implementation and removed --marker and --show-next-marker from sig image-definition list-community and sig image-version list-community - #10068
Open
william051200 wants to merge 3 commits into
Conversation
❌Azure CLI Extensions Breaking Change Test
|
|
Hi @william051200, |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the image-gallery extension’s SIG community-related commands away from vendored mgmt.compute SDK usage to AAZ-based implementations provided by azure.cli.command_modules.vm, and updates command registration accordingly.
Changes:
- Replaced community gallery show/list operations with AAZ-backed wrappers in
custom.py. - Simplified command table registration to use
custom_commandfor community commands. - Removed legacy paging parameters (
--marker,--show-next-marker) and removed unused community client factories.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/image-gallery/azext_image_gallery/custom.py | Swaps SDK-based community gallery operations for AAZ/VM-module wrappers; updates share enable implementation. |
| src/image-gallery/azext_image_gallery/commands.py | Updates command registration to route community commands through new custom wrappers. |
| src/image-gallery/azext_image_gallery/_params.py | Removes legacy pagination arguments from community list commands. |
| src/image-gallery/azext_image_gallery/_client_factory.py | Deletes now-unused community-specific client factory helpers (keeps galleries factory). |
Comment on lines
7
to
+21
| def load_command_table(self, _): | ||
|
|
||
| community_gallery_sdk = CliCommandType( | ||
| operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_galleries_operations#CommunityGalleriesOperations.{}', | ||
| client_factory=cf_community_gallery) | ||
|
|
||
| community_gallery_image_sdk = CliCommandType( | ||
| operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_gallery_images_operations#CommunityGalleryImagesOperations.{}', | ||
| client_factory=cf_community_gallery_image) | ||
|
|
||
| community_gallery_image_version_sdk = CliCommandType( | ||
| operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_gallery_image_versions_operations#CommunityGalleryImageVersionsOperations.{}', | ||
| client_factory=cf_community_gallery_image_version) | ||
|
|
||
| community_gallery_sharing_profile_sdk = CliCommandType( | ||
| operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._gallery_sharing_profile_operations#GallerySharingProfileOperations.{}', | ||
| client_factory=cf_community_gallery_sharing_profile) | ||
|
|
||
| compute_galleries_sdk = CliCommandType( | ||
| operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._galleries_operations#GalleriesOperations.{}', | ||
| client_factory=cf_galleries, | ||
| ) | ||
|
|
||
| with self.command_group('sig', compute_galleries_sdk, client_factory=cf_galleries) as g: | ||
| with self.command_group('sig') as g: | ||
| g.custom_command('create', 'create_image_gallery') | ||
| g.custom_command('show-community', 'sig_community_gallery_show', is_experimental=True) | ||
|
|
||
| with self.command_group('sig', community_gallery_sdk, client_factory=cf_community_gallery) as g: | ||
| g.command('show-community', 'get', is_experimental=True) | ||
|
|
||
| with self.command_group('sig image-definition', community_gallery_image_sdk, | ||
| client_factory=cf_community_gallery_image) as g: | ||
| g.command('show-community', 'get', is_experimental=True) | ||
| with self.command_group('sig image-definition') as g: | ||
| g.custom_command('show-community', 'sig_community_gallery_image_show', is_experimental=True) | ||
| g.custom_command('list-community', 'sig_community_image_definition_list', is_experimental=True) | ||
|
|
||
| with self.command_group('sig image-version', community_gallery_image_version_sdk, | ||
| client_factory=cf_community_gallery_image_version) as g: | ||
| g.command('show-community', 'get', is_experimental=True) | ||
| with self.command_group('sig image-version') as g: | ||
| g.custom_command('show-community', 'sig_community_image_version_show', is_experimental=True) | ||
| g.custom_command('list-community', 'sig_community_image_version_list', is_experimental=True) | ||
|
|
||
| with self.command_group('sig share', community_gallery_sharing_profile_sdk, | ||
| client_factory=cf_community_gallery_sharing_profile) as g: | ||
| g.custom_command('enable-community', 'sig_share_update', supports_no_wait=True) | ||
| with self.command_group('sig share') as g: | ||
| g.custom_command('enable-community', 'sig_share_enable_community', supports_no_wait=True) |
Comment on lines
+104
to
+118
| def sig_share_enable_community(cmd, resource_group_name, gallery_name, subscription_ids=None, tenant_ids=None, | ||
| no_wait=False, op_type=None): | ||
| from azure.cli.command_modules.vm.operations.sig_share import SigShareEnableCommunity | ||
| command_args = { | ||
| 'resource_group': resource_group_name, | ||
| 'gallery_name': gallery_name, | ||
| 'no_wait': no_wait, | ||
| } | ||
| if subscription_ids: | ||
| groups.append(SharingProfileGroup(type=SharingProfileGroupTypes.SUBSCRIPTIONS, ids=subscription_ids)) | ||
| command_args['subscription_ids'] = subscription_ids | ||
| if tenant_ids: | ||
| groups.append(SharingProfileGroup(type=SharingProfileGroupTypes.AAD_TENANTS, ids=tenant_ids)) | ||
| sharing_update = SharingUpdate(operation_type=op_type, groups=groups) | ||
| return client.begin_update(resource_group_name=resource_group_name, | ||
| gallery_name=gallery_name, | ||
| sharing_update=sharing_update) | ||
| command_args['tenant_ids'] = tenant_ids | ||
| if op_type: | ||
| command_args['operation_type'] = op_type | ||
| return SigShareEnableCommunity(cli_ctx=cmd.cli_ctx)(command_args=command_args) |
Comment on lines
39
to
53
| with self.argument_context('sig image-definition list-community') as c: | ||
| c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
| c.argument('public_gallery_name', public_gallery_name_type) | ||
| c.argument('marker', arg_type=marker_type) | ||
| c.argument('show_next_marker', action='store_true', help='Show nextMarker in result when specified.') | ||
|
|
||
| with self.argument_context('sig image-version show-community') as c: | ||
| c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
| c.argument('public_gallery_name', public_gallery_name_type) | ||
| c.argument('gallery_image_name', gallery_image_name_type) | ||
| c.argument('gallery_image_version_name', gallery_image_name_version_type) | ||
|
|
||
| with self.argument_context('sig image-version list-community') as c: | ||
| c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
| c.argument('public_gallery_name', public_gallery_name_type) | ||
| c.argument('gallery_image_name', gallery_image_name_type) | ||
| c.argument('marker', arg_type=marker_type) | ||
| c.argument('show_next_marker', action='store_true', help='Show nextMarker in result when specified.') | ||
|
|
Comment on lines
+16
to
+30
| def sig_community_image_definition_list(cmd, location, public_gallery_name): | ||
| from azure.cli.command_modules.vm.aaz.latest.sig.image_definition import ListCommunity | ||
| return ListCommunity(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'location': location, | ||
| 'public_gallery_name': public_gallery_name, | ||
| }) | ||
|
|
||
|
|
||
| def sig_community_image_version_list(client, location, public_gallery_name, gallery_image_name, marker=None, | ||
| show_next_marker=None): | ||
| generator = client.list(location=location, public_gallery_name=public_gallery_name, | ||
| gallery_image_name=gallery_image_name) | ||
| return get_page_result(generator, marker, show_next_marker) | ||
|
|
||
|
|
||
| def get_page_result(generator, marker, show_next_marker=None): | ||
| pages = generator.by_page(continuation_token=marker) # ContainerPropertiesPaged | ||
| result = list_generator(pages=pages) | ||
|
|
||
| if show_next_marker: | ||
| next_marker = {"nextMarker": pages.continuation_token} | ||
| result.append(next_marker) | ||
| else: | ||
| if pages.continuation_token: | ||
| logger.warning('Next Marker:') | ||
| logger.warning(pages.continuation_token) | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| # The REST service takes 50 items as a page by default | ||
| def list_generator(pages, num_results=50): | ||
| result = [] | ||
|
|
||
| # get first page items | ||
| page = list(next(pages)) | ||
| result += page | ||
|
|
||
| while True: | ||
| if not pages.continuation_token: | ||
| break | ||
|
|
||
| # handle num results | ||
| if num_results is not None: | ||
| if num_results == len(result): | ||
| break | ||
|
|
||
| page = list(next(pages)) | ||
| result += page | ||
|
|
||
| return result | ||
| def sig_community_image_version_list(cmd, location, public_gallery_name, gallery_image_name): | ||
| from azure.cli.command_modules.vm.aaz.latest.sig.image_version import ListCommunity | ||
| return ListCommunity(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'location': location, | ||
| 'public_gallery_name': public_gallery_name, | ||
| 'gallery_image_definition': gallery_image_name, | ||
| }) |
william051200
requested review from
jsntcy,
necusjz and
wangzelin007
as code owners
July 3, 2026 05:28
| "version": "1.0.0b3" | ||
| }, | ||
| "sha256Digest": "6e20da857d440f0f6313f27aa674bd1e0581d7d34a5ce599afebf1e383fa0e0c" | ||
| "sha256Digest": "642c37950ced20df1be589390f018b525e00333555ca1f995a75c064b600b616" |
| def sig_community_image_definition_list(client, location, public_gallery_name, marker=None, show_next_marker=None): | ||
| generator = client.list(location=location, public_gallery_name=public_gallery_name) | ||
| return get_page_result(generator, marker, show_next_marker) | ||
| def sig_community_image_definition_list(cmd, location, public_gallery_name): |
| result += page | ||
|
|
||
| return result | ||
| def sig_community_image_version_list(cmd, location, public_gallery_name, gallery_image_name): |
Comment on lines
+39
to
+41
| def create_image_gallery(cmd, resource_group_name, gallery_name, description=None, location=None, | ||
| no_wait=False, tags=None, permissions=None, soft_delete=None, publisher_uri=None, | ||
| publisher_contact=None, eula=None, public_name_prefix=None): |
| return SigCreate(cli_ctx=cmd.cli_ctx)(command_args=command_args) | ||
|
|
||
|
|
||
| def sig_community_gallery_show(cmd, location, public_gallery_name): |
| }) | ||
|
|
||
|
|
||
| def sig_community_gallery_image_show(cmd, location, public_gallery_name, gallery_image_name): |
Comment on lines
+93
to
+94
| def sig_community_image_version_show(cmd, location, public_gallery_name, gallery_image_name, | ||
| gallery_image_version_name): |
Comment on lines
+104
to
+105
| def sig_share_enable_community(cmd, resource_group_name, gallery_name, subscription_ids=None, tenant_ids=None, | ||
| no_wait=False, op_type=None): |
Comment on lines
+8
to
+9
| * Migrate code from Azure SDK to AAZ based commands for compute operations. | ||
| * Remove `--marker` and `--show-next-marker` from `sig image-definition list-community` and `sig image-version list-community`. AAZ have its own handling for pagination. |
william051200
force-pushed
the
image-gallery-migration
branch
from
July 3, 2026 06:26
3bfb23e to
b97e7d5
Compare
Collaborator
|
image-gallery |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
--marker and --show-next-marker from sig image-definition list-community and sig image-version list-community
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
--marker and --show-next-marker from sig image-definition list-community and sig image-version list-community--marker and --show-next-marker from sig image-definition list-community and sig image-version list-community
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Collaborator
|
image-gallery |
yanzhudd
previously approved these changes
Jul 10, 2026
yanzhudd
reviewed
Jul 10, 2026
| 1.1.0 | ||
| +++++++++++++++ | ||
| * Migrate code from Azure SDK to AAZ based commands for compute operations. | ||
| * Remove `--marker` and `--show-next-marker` from `sig image-definition list-community` and `sig image-version list-community`. AAZ has its own handling for pagination. |
Contributor
There was a problem hiding this comment.
It would be better to specify the new parameters for pagination.
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
william051200
force-pushed
the
image-gallery-migration
branch
from
July 13, 2026 01:28
1c3ed7e to
53fd028
Compare
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation — ❌ Action needed
❌Azure CLI Extensions Breaking Change Test
Migration from mgmt.compute to aaz-based
Replace
--markerand--show-next-markerfromsig image-definition list-communityandsig image-version list-communitywith--max-itemsand--next-token. AAZ has its own handling for pagination.This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (azdevrequired; see.azure-pipelines/templates/azdev_setup.ymlfor the install command untilazdev==0.2.11b1is on PyPI)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.jsonautomatically.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.