New-AzDdosProtectionPlan
Creates a DDoS protection plan.
Syntax
Default (Default)
New-AzDdosProtectionPlan
-ResourceGroupName <String>
-Name <String>
-Location <String>
[-Tag <Hashtable>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-AzDdosProtectionPlan cmdlet creates a DDoS protection plan.
Examples
Example 1: Create and associate a DDoS protection plan with a new virtual network
$ddosProtectionPlan = New-AzDdosProtectionPlan -ResourceGroupName ResourceGroupName -Name DdosProtectionPlanName -Location "West US"
$subnet = New-AzVirtualNetworkSubnetConfig -Name SubnetName -AddressPrefix 10.0.1.0/24
$vnet = New-AzVirtualNetwork -Name VnetName -ResourceGroupName ResourceGroupName -Location "West US" -AddressPrefix 10.0.0.0/16 -DnsServer 8.8.8.8 -Subnet $subnet -EnableDdoSProtection -DdosProtectionPlanId $ddosProtectionPlan.Id
First, we create a new DDoS Protection plan with the New-AzDdosProtectionPlan command.
Then, we create a new virtual network with New-AzVirtualNetwork and we specify the ID of the newly created plan in the parameter DdosProtectionPlanId . In this case, since we are associating the virtual network with a plan, we can also specify the parameter EnableDdoSProtection .
Example 2: Create and associate a DDoS protection plan with an existing virtual network
$ddosProtectionPlan = New-AzDdosProtectionPlan -ResourceGroupName ResourceGroupName -Name DdosProtectionPlanName -Location "West US"
$vnet = Get-AzVirtualNetwork -Name VnetName -ResourceGroupName ResourceGroupName
$vnet.DdosProtectionPlan = New-Object Microsoft.Azure.Commands.Network.Models.PSResourceId
$vnet.DdosProtectionPlan.Id = $ddosProtectionPlan.Id
$vnet.EnableDdosProtection = $true
$vnet | Set-AzVirtualNetwork
Name : VnetName
ResourceGroupName : ResourceGroupName
Location : westus
Id : /subscriptions/d1dbd366-9871-45ac-84b7-fb318152a9e0/resourceGroups/ResourceGroupName/providers/Microsoft.Network/virtualNetworks/VnetName
Etag : W/"fbf41754-3c13-43fd-bb5b-fcc37d5e1cbb"
ResourceGuid : fcb7bc1e-ee0d-4005-b3f1-feda76e3756c
ProvisioningState : Succeeded
Tags :
AddressSpace : {
"AddressPrefixes": [
"10.0.0.0/16"
]
}
DhcpOptions : {
"DnsServers": [
"8.8.8.8"
]
}
Subnets : [
{
"Name": "SubnetName",
"Etag": "W/\"fbf41754-3c13-43fd-bb5b-fcc37d5e1cbb\"",
"Id": "/subscriptions/d1dbd366-9871-45ac-84b7-fb318152a9e0/resourceGroups/ResourceGroupName/providers/Microsoft.Network/virtualNetworks/VnetName/subnets/SubnetName",
"AddressPrefix": "10.0.1.0/24",
"IpConfigurations": [],
"ResourceNavigationLinks": [],
"ServiceEndpoints": [],
"ProvisioningState": "Succeeded"
}
]
VirtualNetworkPeerings : []
EnableDdosProtection : true
DdosProtectionPlan : {
"Id": "/subscriptions/d1dbd366-9871-45ac-84b7-fb318152a9e0/resourceGroups/ResourceGroupName/providers/Microsoft.Network/ddosProtectionPlans/DdosProtectionPlanName"
}
EnableVmProtection : false
First, we create a new DDoS Protection plan with the New-AzDdosProtectionPlan command.
Second, we get the most updated version of the virtual network we want to associate with the plan. We update the property DdosProtectionPlan with a PSResourceId object containing a reference to the ID of the newly created plan. In this case, if we associate the virtual network with a DDoS protection plan, we can also set the flag EnableDdosProtection to true.
Finally, we persist the new state by piping the local variable into Set-AzVirtualNetwork .
Parameters
-AsJob
Run cmdlet in the background
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Location
Specifies the location of the DDoS protection plan to be created.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Name
Specifies the name of the DDoS protection plan to be created.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ResourceName
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceGroupName
Specifies the resource group of the DDoS protection plan to be created.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Tag
A hashtable which represents resource tags.
Parameter properties
Type: Hashtable
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs