Skip to content

Commit 2646e91

Browse files
mchakkaManas Chakka
andauthored
DDoS Per-IP SKU - Phase 1 Changes (#19562)
* original changes * originaal stuff * bunch of changes * small change * new file from test * removing all the New cmdlet changes * one more change * help file from markdown * fix help * changelog * adding enum accepted params Co-authored-by: Manas Chakka <[email protected]>
1 parent f0858c3 commit 2646e91

File tree

12 files changed

+1347
-20
lines changed

12 files changed

+1347
-20
lines changed

src/Network/Network.Test/NrpTeamAlias.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,8 @@ class NrpTeamAlias
7070

7171
// Virtual WAN team
7272
public const string virtualwan = "routeservicedev";
73+
74+
// Ddos team
75+
public const string ddos = "ddosdev";
7376
}
7477
}

src/Network/Network.Test/ScenarioTests/PublicIpAddressTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ public void TestPublicIpStandardSku()
113113
TestRunner.RunTestScript("Test-PublicIpAddressCRUD-StandardSku");
114114
}
115115

116+
[Fact]
117+
[Trait(Category.AcceptanceType, Category.CheckIn)]
118+
[Trait(Category.Owner, NrpTeamAlias.ddos)]
119+
public void TestPublicIpDdosProtection()
120+
{
121+
TestRunner.RunTestScript("Test-PublicIpAddressCRUD-DdosProtection");
122+
}
123+
116124
[Fact]
117125
[Trait(Category.AcceptanceType, Category.CheckIn)]
118126
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]

src/Network/Network.Test/ScenarioTests/PublicIpAddressTests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,63 @@ function Test-PublicIpAddressCRUD-StandardSku
603603
}
604604
}
605605

606+
<#
607+
.SYNOPSIS
608+
Tests creating new simple publicIpAddress with Ddos Protection
609+
#>
610+
function Test-PublicIpAddressCRUD-DdosProtection
611+
{
612+
# Setup
613+
$rgname = Get-ResourceGroupName
614+
$rname = Get-ResourceName
615+
$domainNameLabel = Get-ResourceName
616+
$rglocation = Get-ProviderLocation ResourceManagement
617+
$resourceTypeParent = "Microsoft.Network/publicIpAddresses"
618+
$location = Get-ProviderLocation $resourceTypeParent
619+
620+
try
621+
{
622+
# Create the resource group
623+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
624+
625+
# Create publicIpAddres
626+
$actual = New-AzPublicIpAddress -ResourceGroupName $rgname -name $rname -location $location -AllocationMethod Static -Sku Standard -DomainNameLabel $domainNameLabel -DdosProtectionMode "Enabled"
627+
$expected = Get-AzPublicIpAddress -ResourceGroupName $rgname -name $rname
628+
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
629+
Assert-AreEqual $expected.Name $actual.Name
630+
Assert-AreEqual $expected.Location $actual.Location
631+
Assert-AreEqualObjectProperties $expected.Sku $actual.Sku
632+
Assert-AreEqual "Static" $expected.PublicIpAllocationMethod
633+
Assert-NotNull $expected.IpAddress
634+
Assert-AreEqual "Succeeded" $expected.ProvisioningState
635+
Assert-AreEqual "Enabled" $expected.DdosSettings.ProtectionMode
636+
637+
# list
638+
$list = Get-AzPublicIpAddress -ResourceGroupName $rgname
639+
Assert-AreEqual 1 @($list).Count
640+
Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName
641+
Assert-AreEqual $list[0].Name $actual.Name
642+
Assert-AreEqual $list[0].Location $actual.Location
643+
Assert-AreEqualObjectProperties $list[0].Sku $actual.Sku
644+
Assert-AreEqual "Static" $list[0].PublicIpAllocationMethod
645+
Assert-NotNull $list[0].IpAddress
646+
Assert-AreEqual "Succeeded" $list[0].ProvisioningState
647+
Assert-AreEqual "Enabled" $expected.DdosSettings.ProtectionMode
648+
649+
# delete
650+
$delete = Remove-AzPublicIpAddress -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force
651+
Assert-AreEqual true $delete
652+
653+
$list = Get-AzPublicIpAddress -ResourceGroupName $actual.ResourceGroupName
654+
Assert-AreEqual 0 @($list).Count
655+
}
656+
finally
657+
{
658+
# Cleanup
659+
Clean-ResourceGroup $rgname
660+
}
661+
}
662+
606663
<#
607664
.SYNOPSIS
608665
Tests creating new simple publicIpAddress with Static allocation and global tier.

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.PublicIpAddressTests/TestPublicIpDdosProtection.json

Lines changed: 1189 additions & 0 deletions
Large diffs are not rendered by default.

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- `New-AzApplicationGatewayClientAuthConfiguration`
3636
- `Set-AzApplicationGatewayClientAuthConfiguration`
3737
* Added Uppercase Transform in New-AzApplicationGatewayFirewallCondition
38+
* Added DdosProtectionMode parameter in New-AzPublicIpAddress
3839
* Added ProbeThreshold parameter to Load Balancer Probe
3940
- `AddAzureRmLoadBalancerProbeConfigCommmand.cs`
4041
- `NewAzureRmLoadBalancerProbeConfigCommand.cs`

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ private static void Initialize()
400400
cfg.CreateMap<CNM.PSPublicIpTag, MNM.IpTag>();
401401
cfg.CreateMap<CNM.PSPublicIpAddressSku, MNM.PublicIPAddressSku>();
402402
cfg.CreateMap<CNM.PSPublicIpAddressDnsSettings, MNM.PublicIPAddressDnsSettings>();
403+
cfg.CreateMap<CNM.PSDdosSettings, MNM.DdosSettings>();
403404

404405
// MNM to CNM
405406
cfg.CreateMap<MNM.PublicIPAddress, CNM.PSPublicIpAddress>()
@@ -411,6 +412,7 @@ private static void Initialize()
411412
cfg.CreateMap<MNM.IpTag, CNM.PSPublicIpTag>();
412413
cfg.CreateMap<MNM.PublicIPAddressSku, CNM.PSPublicIpAddressSku>();
413414
cfg.CreateMap<MNM.PublicIPAddressDnsSettings, CNM.PSPublicIpAddressDnsSettings>();
415+
cfg.CreateMap<MNM.DdosSettings, CNM.PSDdosSettings>();
414416

415417
// PublicIpPrefix
416418
// CNM to MNM

src/Network/Network/Models/PSDdosProtectionPlan.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ public class PSDdosProtectionPlan : PSTopLevelResource
2626

2727
public List<PSResourceId> VirtualNetworks { get; set; }
2828

29+
public List<PSResourceId> PublicIpAddresses { get; set; }
30+
2931
[JsonIgnore]
3032
public string VirtualNetworksText
3133
{
3234
get { return JsonConvert.SerializeObject(VirtualNetworks, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
3335
}
36+
37+
[JsonIgnore]
38+
public string PublicIpAddressesText
39+
{
40+
get { return JsonConvert.SerializeObject(PublicIpAddresses, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
41+
}
3442
}
3543
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Network.Models
16+
{
17+
public partial class PSDdosSettings
18+
{
19+
public string ProtectionMode;
20+
}
21+
}

src/Network/Network/Models/PSPublicIpAddress.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class PSPublicIpAddress : PSTopLevelResource
3131

3232
public PSPublicIpAddressDnsSettings DnsSettings { get; set; }
3333

34+
public PSDdosSettings DdosSettings { get; set; }
35+
3436
public List<PSPublicIpTag> IpTags {get; set;}
3537

3638
[Ps1Xml(Target = ViewControl.Table)]

src/Network/Network/Network.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
22

33
<PropertyGroup>
44
<PsModuleName>Network</PsModuleName>
@@ -38,6 +38,7 @@
3838

3939
<ItemGroup>
4040
<Folder Include="Bastion\" />
41+
<Folder Include="Microsoft\Azure\Commands\Network\Models\" />
4142
<Folder Include="RouteServerPeer\" />
4243
</ItemGroup>
4344

0 commit comments

Comments
 (0)