Skip to content

Migrate cdn from az cli to extensions#9786

Open
Ptnan7 wants to merge 10 commits intoAzure:mainfrom
Ptnan7:cdn-ext
Open

Migrate cdn from az cli to extensions#9786
Ptnan7 wants to merge 10 commits intoAzure:mainfrom
Ptnan7:cdn-ext

Conversation

@Ptnan7
Copy link
Copy Markdown
Member

@Ptnan7 Ptnan7 commented Apr 15, 2026


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 wheel==0.30.0 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 April 15, 2026 07:37
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

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

Hi @Ptnan7,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds the generated AAZ (Azure Auto-Generated) command surface and supporting plumbing for the CDN/AFD extension, enabling management operations to move from the Azure CLI core module into this extension.

Changes:

  • Introduces AAZ-generated command groups and commands for az afd (profile/endpoint/origin/origin-group/route/custom-domain/log-analytic/rule).
  • Adds extension-side client factories, validators, and argparse actions previously handled in core.
  • Adds extension documentation and initial changelog entries.

Reviewed changes

Copilot reviewed 88 out of 253 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/cdn/azext_cdn/aaz/init.py Adds package marker for AAZ command package.
src/cdn/azext_cdn/aaz/latest/init.py Adds package marker for latest AAZ commands.
src/cdn/azext_cdn/aaz/latest/afd/init.py Exposes AFD AAZ command group package.
src/cdn/azext_cdn/aaz/latest/afd/__cmd_group.py Registers root az afd command group.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/init.py Exposes az afd custom-domain command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/__cmd_group.py Registers az afd custom-domain command group.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/_delete.py Adds AAZ implementation for az afd custom-domain delete.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/_list.py Adds AAZ implementation for az afd custom-domain list (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/_regenerate_validation_token.py Adds AAZ implementation for az afd custom-domain regenerate-validation-token.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/_show.py Adds AAZ implementation for az afd custom-domain show.
src/cdn/azext_cdn/aaz/latest/afd/custom_domain/_wait.py Adds AAZ implementation for az afd custom-domain wait.
src/cdn/azext_cdn/aaz/latest/afd/endpoint/init.py Exposes az afd endpoint command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/endpoint/__cmd_group.py Registers az afd endpoint command group.
src/cdn/azext_cdn/aaz/latest/afd/endpoint/_delete.py Adds AAZ implementation for az afd endpoint delete.
src/cdn/azext_cdn/aaz/latest/afd/endpoint/_list.py Adds AAZ implementation for az afd endpoint list (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/endpoint/_purge.py Adds AAZ implementation for az afd endpoint purge (LRO).
src/cdn/azext_cdn/aaz/latest/afd/endpoint/_show.py Adds AAZ implementation for az afd endpoint show.
src/cdn/azext_cdn/aaz/latest/afd/endpoint/_wait.py Adds AAZ implementation for az afd endpoint wait.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/init.py Exposes az afd log-analytic command group.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/__cmd_group.py Registers az afd log-analytic command group.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/location/init.py Exposes az afd log-analytic location subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/location/__cmd_group.py Registers az afd log-analytic location subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/location/_list.py Adds az afd log-analytic location list.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/metric/init.py Exposes az afd log-analytic metric subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/metric/__cmd_group.py Registers az afd log-analytic metric subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/metric/_list.py Adds az afd log-analytic metric list.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/ranking/init.py Exposes az afd log-analytic ranking subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/ranking/__cmd_group.py Registers az afd log-analytic ranking subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/ranking/_list.py Adds az afd log-analytic ranking list.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/resource/init.py Exposes az afd log-analytic resource subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/resource/__cmd_group.py Registers az afd log-analytic resource subgroup.
src/cdn/azext_cdn/aaz/latest/afd/log_analytic/resource/_list.py Adds az afd log-analytic resource list.
src/cdn/azext_cdn/aaz/latest/afd/origin/init.py Exposes az afd origin command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/origin/__cmd_group.py Registers az afd origin command group.
src/cdn/azext_cdn/aaz/latest/afd/origin/_delete.py Adds AAZ implementation for az afd origin delete.
src/cdn/azext_cdn/aaz/latest/afd/origin/_list.py Adds AAZ implementation for az afd origin list (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/origin/_show.py Adds AAZ implementation for az afd origin show.
src/cdn/azext_cdn/aaz/latest/afd/origin/_wait.py Adds AAZ implementation for az afd origin wait.
src/cdn/azext_cdn/aaz/latest/afd/origin_group/init.py Exposes az afd origin-group command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/origin_group/__cmd_group.py Registers az afd origin-group command group.
src/cdn/azext_cdn/aaz/latest/afd/origin_group/_delete.py Adds AAZ implementation for az afd origin-group delete.
src/cdn/azext_cdn/aaz/latest/afd/origin_group/_list.py Adds AAZ implementation for az afd origin-group list (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/origin_group/_show.py Adds AAZ implementation for az afd origin-group show.
src/cdn/azext_cdn/aaz/latest/afd/origin_group/_wait.py Adds AAZ implementation for az afd origin-group wait.
src/cdn/azext_cdn/aaz/latest/afd/profile/init.py Exposes az afd profile command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/profile/__cmd_group.py Registers az afd profile command group.
src/cdn/azext_cdn/aaz/latest/afd/profile/_delete.py Adds AAZ implementation for az afd profile delete.
src/cdn/azext_cdn/aaz/latest/afd/profile/_show.py Adds AAZ implementation for az afd profile show.
src/cdn/azext_cdn/aaz/latest/afd/profile/_usage.py Adds AAZ implementation for az afd profile usage (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/profile/_wait.py Adds AAZ implementation for az afd profile wait.
src/cdn/azext_cdn/aaz/latest/afd/profile/identity/init.py Exposes az afd profile identity subgroup and commands.
src/cdn/azext_cdn/aaz/latest/afd/profile/identity/__cmd_group.py Registers az afd profile identity subgroup.
src/cdn/azext_cdn/aaz/latest/afd/profile/identity/_wait.py Adds AAZ implementation for az afd profile identity wait.
src/cdn/azext_cdn/aaz/latest/afd/profile/log_scrubbing/init.py Exposes az afd profile log-scrubbing subgroup.
src/cdn/azext_cdn/aaz/latest/afd/profile/log_scrubbing/__cmd_group.py Registers az afd profile log-scrubbing subgroup.
src/cdn/azext_cdn/aaz/latest/afd/route/init.py Exposes az afd route command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/route/__cmd_group.py Registers az afd route command group.
src/cdn/azext_cdn/aaz/latest/afd/route/_delete.py Adds AAZ implementation for az afd route delete.
src/cdn/azext_cdn/aaz/latest/afd/route/_list.py Adds AAZ implementation for az afd route list (+ paging).
src/cdn/azext_cdn/aaz/latest/afd/route/_show.py Adds AAZ implementation for az afd route show.
src/cdn/azext_cdn/aaz/latest/afd/route/_wait.py Adds AAZ implementation for az afd route wait.
src/cdn/azext_cdn/aaz/latest/afd/rule/init.py Exposes az afd rule command group and commands.
src/cdn/azext_cdn/aaz/latest/afd/rule/__cmd_group.py Registers az afd rule command group.
src/cdn/azext_cdn/_actions.py Adds custom argparse action for origin parsing.
src/cdn/azext_cdn/_client_factory.py Adds mgmt client factory functions for extension commands.
src/cdn/azext_cdn/_validators.py Adds origin validation helper for CLI args.
src/cdn/azext_cdn/init.py Wires extension command loader + AAZ command table loading.
src/cdn/README.md Adds extension-level README describing command groups.
src/cdn/HISTORY.rst Adds initial release history entry for the extension.

# --------------------------------------------------------------------------------------------


def cf_cdn(cli_ctx, *kwargs): # pylint: disable=unused-argument
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The cf_cdn factory is using *kwargs instead of **kwargs. This breaks the conventional client-factory signature (callers passing keyword arguments will raise a TypeError). Change the parameter to **kwargs (or **_ if intentionally unused).

Suggested change
def cf_cdn(cli_ctx, *kwargs): # pylint: disable=unused-argument
def cf_cdn(cli_ctx, **kwargs): # pylint: disable=unused-argument

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +18
msg = "{0} port for origin named {1} is outside of range (1 - 65535)."
for idx, origin in enumerate(namespace.origins):
origin.name = "{}-{}".format(origin.name, idx)
check_port_range(origin.http_port, msg.format('HTTP', origin.name))
check_port_range(origin.https_port, msg.format('HTTPS', origin.name))
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The error message formatting currently drops the actual invalid port value: msg is fully formatted before being passed into check_port_range, so msg.format(port) has no placeholder left to fill. Consider either (a) passing an unformatted template into check_port_range and formatting it once with port included, or (b) removing .format(port) and incorporating the port into the message before calling check_port_range.

Suggested change
msg = "{0} port for origin named {1} is outside of range (1 - 65535)."
for idx, origin in enumerate(namespace.origins):
origin.name = "{}-{}".format(origin.name, idx)
check_port_range(origin.http_port, msg.format('HTTP', origin.name))
check_port_range(origin.https_port, msg.format('HTTPS', origin.name))
msg = "{0} port for origin named {1} with value {2} is outside of range (1 - 65535)."
for idx, origin in enumerate(namespace.origins):
origin.name = "{}-{}".format(origin.name, idx)
check_port_range(origin.http_port, msg.format('HTTP', origin.name, '{0}'))
check_port_range(origin.https_port, msg.format('HTTPS', origin.name, '{0}'))

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +21
"""Delete an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified parameters. Deleting a profile will result in the deletion of all of the sub-resources including endpoints, origins and custom domains.

:example: Delete an AFD profile.
az profile delete -g group --profile-name profile
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The example command appears to be incorrect for this command group: az profile delete should be az afd profile delete (and the docstring has a double space in 'existing Azure'). Updating the example avoids misleading users and aligns with the registered command name.

Suggested change
"""Delete an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified parameters. Deleting a profile will result in the deletion of all of the sub-resources including endpoints, origins and custom domains.
:example: Delete an AFD profile.
az profile delete -g group --profile-name profile
"""Delete an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified parameters. Deleting a profile will result in the deletion of all of the sub-resources including endpoints, origins and custom domains.
:example: Delete an AFD profile.
az afd profile delete -g group --profile-name profile

Copilot uses AI. Check for mistakes.
"afd route list",
)
class List(AAZCommand):
"""List all of the existing origins within a profile.
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This is the implementation for az afd route list, but the docstring says it lists 'origins'. This should describe listing routes under an AFD endpoint to avoid confusing users reading az afd route list -h.

Suggested change
"""List all of the existing origins within a profile.
"""List all of the existing routes under an AFD endpoint.

Copilot uses AI. Check for mistakes.

@property
def method(self):
return "POST"
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The usages endpoint for ARM resource usage is a read operation; this command is modeled as POST. If the service endpoint is /usages, it should be GET to match ARM semantics and avoid 405/operation failures.

Suggested change
return "POST"
return "GET"

Copilot uses AI. Check for mistakes.
_args_schema = cls._args_schema
_args_schema.profile_name = AAZStrArg(
options=["--profile-name"],
help="Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group.",
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The help text contains a duplicated fragment ('which is unique within the resource group. which is unique within the resource group.'). Remove the repetition to improve CLI help readability.

Suggested change
help="Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group.",
help="Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group.",

Copilot uses AI. Check for mistakes.
"""Updates the domain validation token.

:example: Regenerate the domain validation token.
az afd custom-domain regenerate-validation-token -g MyResourceGroup --profile-name MyProfle --custom-domain-name MyCustomDomain
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Typo in the example: 'MyProfle' should be 'MyProfile' to avoid copy/paste errors.

Suggested change
az afd custom-domain regenerate-validation-token -g MyResourceGroup --profile-name MyProfle --custom-domain-name MyCustomDomain
az afd custom-domain regenerate-validation-token -g MyResourceGroup --profile-name MyProfile --custom-domain-name MyCustomDomain

Copilot uses AI. Check for mistakes.
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 15, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

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>

@github-actions
Copy link
Copy Markdown
Contributor

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Copy Markdown
Contributor

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

@necusjz
Copy link
Copy Markdown
Member

necusjz commented Apr 16, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

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

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) require an authorized user to comment /azp run to run.

@necusjz
Copy link
Copy Markdown
Member

necusjz commented Apr 16, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

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

@yonzhan yonzhan requested a review from necusjz April 16, 2026 04:37
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