Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{DisconnectedOperations} Added az edge disconnected-operation edge-marketplace offer command #30980

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from

Conversation

kotewar
Copy link
Member

@kotewar kotewar commented Mar 7, 2025

Related command

az edge disconnected-operation (new)

Description

This PR adds support for packaging Microsoft.edgemarketplace images.

Corresponding AAZ PR: Azure/aaz#710

Testing Guide

az edge disconnected-operation edge-marketplace offer list
az edge disconnected-operation edge-marketplace offer get
az edge disconnected-operation edge-marketplace offer package

History Notes


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

Copy link

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

Copy link

github-actions bot commented Mar 7, 2025

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>

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 7, 2025

DisconnectedOperations

@kotewar
Copy link
Member Author

kotewar commented Mar 8, 2025

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


# Register the parent command group
with self.command_group(
"disconnectedoperations",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use edge disconnected-operation as the top level command group

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be okay if edge keyword repeats? the command would look something like
az edge disconnected-operation edge-marketplace offer list


# Register the subgroup and its commands
with self.command_group(
"disconnectedoperations edgemarketplace",
Copy link
Contributor

Choose a reason for hiding this comment

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

please separate the edgemarketplace by -

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 86 to 92
g.custom_command(
"listoffers", "list_offers", table_transformer=transform_offers_table
)
g.custom_command(
"getoffer", "get_offer", table_transformer=transform_offer_table
)
g.custom_command("packageoffer", "package_offer")
Copy link
Contributor

Choose a reason for hiding this comment

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

the command should be renamed as offer list offer show and offer package based on cli command name guideline

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines +136 to +148
logger = get_logger(__name__)
management_endpoint = _get_management_endpoint(cmd.cli_ctx)
subscription_id = get_subscription_id(cmd.cli_ctx)

# Construct URL with parameters
url = (
f"https://{management_endpoint}"
f"/subscriptions/{subscription_id}"
f"/resourceGroups/{resource_group_name}"
f"/providers/{provider_namespace}/dataBoxEdgeDevices/{resource_name}"
f"/providers/{sub_provider}/offers/{publisher_name}:{offer_name}"
f"?api-version={api_version}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

For the arm request, please use the aaz-dev-tools to generate atomic command, then you can use it directly in your custom functions. Like this

def recover_log_analytics_workspace(cmd, workspace_name, resource_group_name=None, no_wait=False):
from azure.cli.command_modules.monitor.aaz.latest.monitor.log_analytics.workspace import Create, \
ListDeletedWorkspaces
deleted_workspaces = ListDeletedWorkspaces(cli_ctx=cmd.cli_ctx)(command_args={
"resource_group": resource_group_name
})
for deleted_workspace in deleted_workspaces:
if deleted_workspace['name'].lower() == workspace_name.lower():
resource_group_name = _parse_id(deleted_workspace['id'])['resource-group']
location = deleted_workspace['location']
return Create(cli_ctx=cmd.cli_ctx)(command_args={
"workspace_name": deleted_workspace['name'],
"resource_group": resource_group_name,
"location": location,
"no_wait": no_wait,
})
raise InvalidArgumentValueError('{} is not a deleted workspace and you can only recover a deleted workspace '
'within 14 days.'.format(workspace_name))

@kairu-ms
Copy link
Contributor

BTW, this module should be delivered as an extension.


from azure.cli.command_modules.disconnectedoperations._client_factory import cf_image
from azure.cli.core import AzCommandsLoader

Copy link
Contributor

Choose a reason for hiding this comment

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

Please input the _help.py here like this

from azure.cli.command_modules.monitor._help import helps # pylint: disable=unused-import

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@kotewar
Copy link
Member Author

kotewar commented Mar 11, 2025

BTW, this module should be delivered as an extension.

@kairu-ms We actually need this module in a disconnected environment, so internet won't be there to install any extension on top of the CLI.

@kotewar kotewar changed the title {DisconnectedOperations} Added az disconnectedoperations edgemarketplace packageoffer command {DisconnectedOperations} Added az disconnectedoperations edge-marketplace offer command Mar 11, 2025
@kotewar kotewar changed the title {DisconnectedOperations} Added az disconnectedoperations edge-marketplace offer command {DisconnectedOperations} Added az edge disconnected-operation edge-marketplace offer command Mar 11, 2025
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.

4 participants