Skip to content
11 changes: 11 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -6244,3 +6244,14 @@
--resource-type vpnConnection --storage-account MyStorageAccount \\
--storage-path https://{storageAccountName}.blob.core.windows.net/{containerName}
"""

helps['network ddos-custom-policy create'] = """
type: command
short-summary: Create a DDoS custom policy.
examples:
- name: Create DDoS custom policy
text: |
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
"""
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,3 +843,15 @@ def load_arguments(self, _):
c.argument('resource_group_name', required=False)
c.argument('resource_name', required=False, help='Name of the resource')
# endregion

# region DdosCustomPolicy
with self.argument_context('network ddos-custom-policy create') as c:
c.argument('ddos_custom_policy_name', options_list=['--ddos-custom-policy-name', '--name', '-n'], help='The name of the DDoS custom policy.')
c.argument('location', arg_group='Parameters', help='Resource location.')
c.argument('tags', arg_group='Parameters', help='Resource tags.')
c.argument('detection_rule_name', arg_group='Detection Rules', help='The name of the DDoS detection rule.')
c.argument('detection_mode', arg_group='Detection Rules', help='The detection mode for the DDoS detection rule.')
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.')
c.argument('packets_per_second', arg_group='Detection Rules', help='The customized packets per second threshold.')
c.argument('ip_config_id', nargs='+', arg_group='Front End Ip Configuration', help='The frontend IP configurations associated with the custom policy.')
# endregion
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,40 @@ def build_vpn_connection_resource(cmd, name, location, tags, gateway1, gateway2,
'properties': vpn_properties if vpn_type != 'VpnClient' else {}
}
return vpn_connection


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=None, ip_config_id=None):
policy = {'ddos_custom_policy_name': ddos_custom_policy_name}

if location:
policy['location'] = location

if tags:
policy['tags'] = tags

detection_rules = {}
traffic_detection_rule = {}

if detection_rule_name:
detection_rules['name'] = detection_rule_name

if detection_mode:
detection_rules['detection_mode'] = detection_mode

if packets_per_second:
traffic_detection_rule['packets_per_second'] = packets_per_second

if traffic_type:
traffic_detection_rule['traffic_type'] = traffic_type

detection_rules['traffic_detection_rule'] = traffic_detection_rule
policy['detection_rules'] = [detection_rules]

if ip_config_id:
front_end_ip_configuration = []
for config_id in ip_config_id:
front_end_ip_configuration.append({'id': config_id})
policy['front_end_ip_configuration'] = front_end_ip_configuration

return policy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"network ddos-custom-policy",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Ddos Custom Policy
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._show import *
from ._update import *
from ._wait import *
Loading