Skip to content

Commit 366d493

Browse files
{Network} Add DDoS Protection feature: DDoS Policy Customization (#32673)
1 parent eb51746 commit 366d493

15 files changed

Lines changed: 2940 additions & 0 deletions

File tree

src/azure-cli/azure/cli/command_modules/network/_help.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6244,3 +6244,14 @@
62446244
--resource-type vpnConnection --storage-account MyStorageAccount \\
62456245
--storage-path https://{storageAccountName}.blob.core.windows.net/{containerName}
62466246
"""
6247+
6248+
helps['network ddos-custom-policy create'] = """
6249+
type: command
6250+
short-summary: Create a DDoS custom policy.
6251+
examples:
6252+
- name: Create DDoS custom policy
6253+
text: |
6254+
az network ddos-custom-policy create --resource-group rg1 --ddos-custom-policy-name test-ddos-custom-policy \\
6255+
--location centraluseuap --detection-rule-name detectionRuleTcp \\
6256+
--detection-mode TrafficThreshold --traffic-type Tcp --packets-per-second 1000000
6257+
"""

src/azure-cli/azure/cli/command_modules/network/_params.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,3 +843,14 @@ def load_arguments(self, _):
843843
c.argument('resource_group_name', required=False)
844844
c.argument('resource_name', required=False, help='Name of the resource')
845845
# endregion
846+
847+
# region DdosCustomPolicy
848+
with self.argument_context('network ddos-custom-policy create') as c:
849+
c.argument('ddos_custom_policy_name', options_list=['--ddos-custom-policy-name', '--name', '-n'], help='The name of the DDoS custom policy.')
850+
c.argument('location', arg_group='Parameters', help='Resource location.')
851+
c.argument('tags', arg_group='Parameters', help='Resource tags.')
852+
c.argument('detection_rule_name', arg_group='Detection Rules', help='The name of the DDoS detection rule.')
853+
c.argument('detection_mode', arg_group='Detection Rules', help='The detection mode for the DDoS detection rule.')
854+
c.argument('traffic_type', arg_group='Detection Rules', help='The traffic type (one of Tcp, Udp, TcpSyn) that the detection rule will be applied upon.')
855+
c.argument('packets_per_second', arg_group='Detection Rules', help='The customized packets per second threshold.')
856+
# endregion

src/azure-cli/azure/cli/command_modules/network/_template_builder.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,34 @@ def build_vpn_connection_resource(cmd, name, location, tags, gateway1, gateway2,
517517
'properties': vpn_properties if vpn_type != 'VpnClient' else {}
518518
}
519519
return vpn_connection
520+
521+
522+
def build_ddos_custom_policy(cmd, ddos_custom_policy_name, location=None, tags=None, detection_rule_name=None,
523+
detection_mode=None, packets_per_second=None, traffic_type=None):
524+
policy = {'ddos_custom_policy_name': ddos_custom_policy_name}
525+
526+
if location:
527+
policy['location'] = location
528+
529+
if tags:
530+
policy['tags'] = tags
531+
532+
detection_rules = {}
533+
traffic_detection_rule = {}
534+
535+
if detection_rule_name:
536+
detection_rules['name'] = detection_rule_name
537+
538+
if detection_mode:
539+
detection_rules['detection_mode'] = detection_mode
540+
541+
if packets_per_second:
542+
traffic_detection_rule['packets_per_second'] = packets_per_second
543+
544+
if traffic_type:
545+
traffic_detection_rule['traffic_type'] = traffic_type
546+
547+
detection_rules['traffic_detection_rule'] = traffic_detection_rule
548+
policy['detection_rules'] = [detection_rules]
549+
550+
return policy
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"network ddos-custom-policy",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Ddos Custom Policy
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._create import *
13+
from ._delete import *
14+
from ._show import *
15+
from ._update import *
16+
from ._wait import *

0 commit comments

Comments
 (0)