Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cdn/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

1.0.0b1
+++++++
* Initial release. Migrated from azure-cli core CDN command module.
8 changes: 8 additions & 0 deletions src/cdn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Azure CLI CDN and AFD Extension

This extension provides commands for managing Azure CDN and Azure Front Door (AFD) resources.

## Command Groups

- `az cdn` — Manage Azure CDN profiles, endpoints, origins, custom domains, WAF policies
- `az afd` — Manage Azure Front Door profiles, endpoints, origins, routes, rules, secrets, security policies
40 changes: 40 additions & 0 deletions src/cdn/azext_cdn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=unused-import
import azext_cdn._help

from azure.cli.core import AzCommandsLoader


class CdnCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
cdn_custom = CliCommandType(operations_tmpl='azext_cdn.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=cdn_custom)

def load_command_table(self, args):
from .commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from ._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = CdnCommandsLoader
39 changes: 39 additions & 0 deletions src/cdn/azext_cdn/_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import argparse


# pylint:disable=protected-access
# pylint:disable=too-few-public-methods
class OriginType(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
deep_created_origin = self.get_origin(values, option_string)
super().__call__(parser, namespace, deep_created_origin, option_string)

def get_origin(self, values, option_string):
from azure.mgmt.cdn.models import DeepCreatedOrigin

if not 1 <= len(values) <= 3 and not 5 <= len(values) <= 6:
msg = '%s takes 1, 2, 3, 5, or 6 values, %d given'
raise argparse.ArgumentError(
self, msg % (option_string, len(values)))

deep_created_origin = DeepCreatedOrigin(
name='origin',
host_name=values[0],
http_port=80,
https_port=443)

if len(values) > 1:
deep_created_origin.http_port = int(values[1])
if len(values) > 2:
deep_created_origin.https_port = int(values[2])
if len(values) > 4:
deep_created_origin.private_link_resource_id = values[3]
deep_created_origin.private_link_location = values[4]
if len(values) > 5:
deep_created_origin.private_link_approval_message = values[5]
return deep_created_origin
90 changes: 90 additions & 0 deletions src/cdn/azext_cdn/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


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.
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.cdn import CdnManagementClient
return get_mgmt_service_client(cli_ctx, CdnManagementClient)


def cf_custom_domain(cli_ctx, _):
return cf_cdn(cli_ctx).custom_domains


def cf_endpoints(cli_ctx, _):
return cf_cdn(cli_ctx).endpoints


def cf_profiles(cli_ctx, _):
return cf_cdn(cli_ctx).profiles


def cf_afd_profiles(cli_ctx, _):
return cf_cdn(cli_ctx).afd_profiles


def cf_origins(cli_ctx, _):
return cf_cdn(cli_ctx).origins


def cf_origin_groups(cli_ctx, _):
return cf_cdn(cli_ctx).origin_groups


def cf_resource_usage(cli_ctx, _):
return cf_cdn(cli_ctx).resource_usage


def cf_edge_nodes(cli_ctx, _):
return cf_cdn(cli_ctx).edge_nodes


def cf_waf_policy(cli_ctx, _):
return cf_cdn(cli_ctx).policies


def cf_waf_rule_set(cli_ctx, _):
return cf_cdn(cli_ctx).managed_rule_sets


def cf_afd_endpoints(cli_ctx, _):
return cf_cdn(cli_ctx).afd_endpoints


def cf_afd_origin_groups(cli_ctx, _):
return cf_cdn(cli_ctx).afd_origin_groups


def cf_afd_origins(cli_ctx, _):
return cf_cdn(cli_ctx).afd_origins


def cf_afd_routes(cli_ctx, _):
return cf_cdn(cli_ctx).routes


def cf_afd_rule_sets(cli_ctx, _):
return cf_cdn(cli_ctx).rule_sets


def cf_afd_rules(cli_ctx, _):
return cf_cdn(cli_ctx).rules


def cf_afd_security_policies(cli_ctx, _):
return cf_cdn(cli_ctx).security_policies


def cf_afd_custom_domain(cli_ctx, _):
return cf_cdn(cli_ctx).afd_custom_domains


def cf_afd_secrets(cli_ctx, _):
return cf_cdn(cli_ctx).secrets


def cf_afd_log_analytics(cli_ctx, _):
return cf_cdn(cli_ctx).log_analytics
Loading
Loading