Skip to content

Conversation

@william051200
Copy link
Member

Related command

az network ddos-custom-policy create
az network ddos-custom-policy update
az network ddos-custom-policy delete
az network ddos-custom-policy show

Description

Resolve #32529

aaz Azure/aaz#923

Testing Guide

Create custom policy with rule
az network ddos-custom-policy create --detection-rule-name --detection-mode --traffic-type --packets-per-second

Show and validate created custom policy
az network ddos-custom-policy show

Create a second rule within the same policy
az network ddos-custom-policy create --detection-rule-name --detection-mode --traffic-type --packets-per-second

Update first rule name and make sure the second rule stays the same
az network ddos-custom-policy update --set detectionRules[0].name=<name>

Remove first rule and make sure it only have 1 rule left and it is the second rule
az network ddos-custom-policy update --remove detectionRules 0

Delete the policy and make sure it is deleted
az network ddos-custom-policy delete

History Notes

[Network] az network ddos-custom-policy: Support DDoS Policy Customization


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

@william051200 william051200 requested a review from jsntcy as a code owner January 20, 2026 02:56
Copilot AI review requested due to automatic review settings January 20, 2026 02:56
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jan 20, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

Hi @william051200,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 20, 2026

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

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

azure-client-tools-bot-prd bot commented Jan 20, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️network
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd network ddos-custom-policy sub group network ddos-custom-policy added

@github-actions
Copy link

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>

Copy link
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

This PR adds support for DDoS Policy Customization by introducing new commands to manage DDoS custom policies in Azure CLI. The implementation includes commands for creating, updating, deleting, and showing DDoS custom policies with detection rules.

Changes:

  • Added new command group az network ddos-custom-policy with create, update, delete, show, and wait commands
  • Implemented custom create logic to support adding detection rules to existing policies
  • Added comprehensive test coverage for the new functionality

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test_network_commands.py Added comprehensive scenario tests for DDoS custom policy CRUD operations
commands.py Registered new ddos-custom-policy command group
custom.py Implemented custom create logic with policy merging and format conversion
_template_builder.py Added builder function for constructing DDoS custom policy objects
_params.py Defined command parameters for create operation
_help.py Added help documentation with examples
AAZ generated files Auto-generated command implementations for create, update, delete, show, and wait

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# region DdosCustomPolicy
with self.command_group('network ddos-custom-policy') as g:
g.custom_show_command('create', 'create_ddos_custom_policy', supports_no_wait=True)
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The command is registered using 'custom_show_command' which is incorrect. The 'create' command should be registered using 'custom_command' instead, as it's not a show/read operation. Using 'custom_show_command' for a create operation is semantically incorrect and could lead to unexpected behavior or confusion.

Suggested change
g.custom_show_command('create', 'create_ddos_custom_policy', supports_no_wait=True)
g.custom_command('create', 'create_ddos_custom_policy', supports_no_wait=True)

Copilot uses AI. Check for mistakes.


def build_ddos_custom_policy(cmd, ddos_custom_policy_name, location=None, tags=None, detection_rule_name=None,
detection_mode=None, packets_per_second=None, traffic_type=False, ip_config_id=None):
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The parameter 'traffic_type' has a default value of 'False' (boolean) when it should likely be 'None' or not have a default value. This parameter is supposed to be a string representing traffic type (Tcp, Udp, TcpSyn), not a boolean. This will cause incorrect behavior when the parameter is not provided.

Suggested change
detection_mode=None, packets_per_second=None, traffic_type=False, ip_config_id=None):
detection_mode=None, packets_per_second=None, traffic_type=None, ip_config_id=None):

Copilot uses AI. Check for mistakes.
Comment on lines 6738 to 6739
except Exception as err:
pass
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The exception handling uses a bare 'except Exception' with 'pass', silently ignoring all exceptions. This could hide important errors. Consider catching specific exceptions (e.g., ResourceNotFoundError) or at minimum logging the exception for debugging purposes.

Suggested change
except Exception as err:
pass
except ResourceNotFoundError:
# No existing DDoS custom policy; proceed with creation.
logger.debug("DDoS custom policy '%s' not found in resource group '%s'.",
ddos_custom_policy_name, resource_group_name)
except Exception as err: # pylint: disable=broad-except
# Log unexpected errors while preserving previous behavior of not failing the command.
logger.warning("Failed to retrieve existing DDoS custom policy '%s' in resource group '%s': %s",
ddos_custom_policy_name, resource_group_name, err)

Copilot uses AI. Check for mistakes.
Comment on lines 6254 to 6256
az network ddos-custom-policy create --resource-group rg1 --ddos-custom-policy-name test-
ddos-custom-policy --location centraluseuap --detection-rule-name detectionRuleTcp
--detection-mode TrafficThreshold --traffic-type Tcp --packets-per-second 1000000
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The help text for the create command example is split across lines 6254-6256 in an awkward way that will result in improper formatting. The command should be written on a single line or use proper line continuation to ensure it displays correctly in the help output.

Suggested change
az network ddos-custom-policy create --resource-group rg1 --ddos-custom-policy-name test-
ddos-custom-policy --location centraluseuap --detection-rule-name detectionRuleTcp
--detection-mode TrafficThreshold --traffic-type Tcp --packets-per-second 1000000
az network ddos-custom-policy create --resource-group rg1 --ddos-custom-policy-name test-ddos-custom-policy \\
--location centraluseuap --detection-rule-name detectionRuleTcp \\
--detection-mode TrafficThreshold --traffic-type Tcp --packets-per-second 1000000

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI support for new DDoS Protection feature: DDoS Policy Customization

3 participants