Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ResourceManager/Network/AzureRM.Network.Netcore.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
'New-AzureRmApplicationSecurityGroup',
'Remove-AzureRmApplicationSecurityGroup',
'Get-AzureRmApplicationSecurityGroup',
'New-AzureRmPublicIpTag'
'New-AzureRmPublicIpTag',
'New-AzureRmDdosProtectionPlan',
'Get-AzureRmDdosProtectionPlan',
'Remove-AzureRmDdosProtectionPlan'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
8 changes: 6 additions & 2 deletions src/ResourceManager/Network/AzureRM.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,12 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
'Get-AzureRmVirtualNetworkGatewaySupportedVpnDevice',
'Get-AzureRmVirtualNetworkGatewayConnectionVpnDeviceConfigScript',
'New-AzureRmApplicationSecurityGroup',
'Remove-AzureRmApplicationSecurityGroup',
'Get-AzureRmApplicationSecurityGroup', 'New-AzureRmPublicIpTag'
'Remove-AzureRmApplicationSecurityGroup',
'Get-AzureRmApplicationSecurityGroup',
'New-AzureRmPublicIpTag',
'New-AzureRmDdosProtectionPlan',
'Get-AzureRmDdosProtectionPlan',
'Remove-AzureRmDdosProtectionPlan'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

## Current Release
* Set minimum dependency of module to PowerShell 5.0
* Add support for DDoS protection plan resource
* Introduced multiple breaking changes
- Please refer to the migration guide for more information

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=17.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.17.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=18.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.18.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager">
Expand Down Expand Up @@ -170,6 +170,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NetworkResourcesController.cs" />
<Compile Include="ScenarioTests\ApplicationGatewayTests.cs" />
<Compile Include="ScenarioTests\DdosProtectionPlanTests.cs" />
<Compile Include="ScenarioTests\ApplicationSecurityGroupTests.cs" />
<Compile Include="ScenarioTests\AvailableEndpointServicesTests.cs" />
<Compile Include="ScenarioTests\MultiIpConfigOnNicTests.cs" />
Expand Down Expand Up @@ -204,6 +205,9 @@
<None Include="ScenarioTests\ApplicationGatewayTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DdosProtectionPlanTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ApplicationSecurityGroupTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -312,6 +316,15 @@
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.AvailableEndpointServicesTests\TestAvailableEndpointServicesList.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.DdosProtectionPlanTests\TestDdosProtectionPlanCollections.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.DdosProtectionPlanTests\TestDdosProtectionPlanCrud.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.DdosProtectionPlanTests\TestDdosProtectionPlanCrudWithVirtualNetwork.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.ExpressRouteCircuitTests\TestExpressRouteBgpServiceCommunitiesGet.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;
using Xunit.Abstractions;

namespace Commands.Network.Test.ScenarioTests
{
public class DdosProtectionPlanTests : RMTestBase
{
public DdosProtectionPlanTests(ITestOutputHelper output)
{
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDdosProtectionPlanCrud()
{
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-DdosProtectionPlanCRUD"));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDdosProtectionPlanCrudWithVirtualNetwork()
{
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-DdosProtectionPlanCRUDWithVirtualNetwork"));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDdosProtectionPlanCollections()
{
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-DdosProtectionPlanCollections"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# ----------------------------------------------------------------------------------
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
DDoS protection plan management operations
#>
function Test-DdosProtectionPlanCRUD
{
$rgLocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/DdosProtectionPlans"
$location = Get-ProviderLocation $resourceTypeParent

$rgName = Get-ResourceGroupName
$ddosProtectionPlanName = Get-ResourceName

try
{
# Create the resource group
New-AzureRmResourceGroup -Name $rgName -Location $location -Tags @{ testtag = "ddosProtectionPlan tag" }

# Create the DDoS protection plan
$job = New-AzureRmDdosProtectionPlan -ResourceGroupName $rgName -Name $ddosProtectionPlanName -Location $rgLocation -AsJob
$job | Wait-Job
$ddosProtectionPlanNew = $job | Receive-Job

Assert-AreEqual $rgName $ddosProtectionPlanNew.ResourceGroupName
Assert-AreEqual $ddosProtectionPlanName $ddosProtectionPlanNew.Name
Assert-NotNull $ddosProtectionPlanNew.Location
Assert-NotNull $ddosProtectionPlanNew.Etag
Assert-Null $ddosProtectionPlanNew.VirtualMachines

# Get the DDoS protection plan
$ddosProtectionPlanGet = Get-AzureRmDdosProtectionPlan -ResourceGroupName $rgName -Name $ddosProtectionPlanName
Assert-AreEqual $rgName $ddosProtectionPlanGet.ResourceGroupName
Assert-AreEqual $ddosProtectionPlanName $ddosProtectionPlanGet.Name
Assert-NotNull $ddosProtectionPlanGet.Location
Assert-NotNull $ddosProtectionPlanGet.Etag
Assert-Null $ddosProtectionPlanGet.VirtualMachines

# Remove the DDoS protection plan
$ddosProtectionPlanDelete = Remove-AzureRmDdosProtectionPlan -Name $ddosProtectionPlanName -ResourceGroupName $rgName -PassThru
Assert-AreEqual $true $ddosProtectionPlanDelete
}
finally
{
# Cleanup
Clean-ResourceGroup $rgName
}
}

<#
.SYNOPSIS
Tests the creation of a new DDoS protection plan and it associates it with a VNET.
#>
function Test-DdosProtectionPlanCRUDWithVirtualNetwork
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$subnetName = Get-ResourceName
$ddosProtectionPlanName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
$location = Get-ProviderLocation $resourceTypeParent

try
{
# Create the resource group

New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }

# Create the DDoS Protection plan

$ddosProtectionPlan = New-AzureRmDdosProtectionPlan -Name $ddosProtectionPlanName -ResourceGroupName $rgname -Location $location

# Create a Virtual Network with the DDoS protection plan

$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -DnsServer 8.8.8.8 -Subnet $subnet -EnableDdoSProtection -DdosProtectionPlanId $ddosProtectionPlan.Id

Assert-AreEqual true $vnet.EnableDdoSProtection
Assert-AreEqual $ddosProtectionPlan.Id $vnet.DdosProtectionPlan.Id

# Verify DDoS protection now shows the associated VNET

$ddosProtectionPlanWithVnet = Get-AzureRmDdosProtectionPlan -Name $ddosProtectionPlanName -ResourceGroupName $rgname

Assert-AreEqual $vnet.Id $ddosProtectionPlanWithVnet.VirtualNetworks[0].Id

# Delete the virtual network

$deleteVnet = Remove-AzureRmvirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
Assert-AreEqual true $deleteVnet

# Delete the DDoS protection plan

$deleteDdosProtectionPlan = Remove-AzureRmDdosProtectionPlan -ResourceGroupName $rgname -name $ddosProtectionPlanName -PassThru
Assert-AreEqual true $deleteDdosProtectionPlan
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
DDoS protection plan collection operations
#>
function Test-DdosProtectionPlanCollections
{
$rgLocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/DdosProtectionPlans"
$location = Get-ProviderLocation $resourceTypeParent
$rgName = Get-ResourceGroupName
$ddosProtectionPlanName = Get-ResourceName

try
{
# Create the resource group

New-AzureRmResourceGroup -Name $rgName -Location $location -Tags @{ testtag = "ddosProtectionPlan tag" }

# Create ddosProtectionPlan in resource group

$ddosProtectionPlan = New-AzureRmDdosProtectionPlan -Name $ddosProtectionPlanName -ResourceGroupName $rgName -Location $rgLocation

# Get the ddosProtectionPlan in the resource group by using the collections API

$listRg = Get-AzureRmDdosProtectionPlan -ResourceGroupName $rgName
Assert-AreEqual 1 @($listRg).Count
Assert-AreEqual $listRg[0].ResourceGroupName $ddosProtectionPlan.ResourceGroupName
Assert-AreEqual $listRg[0].Name $ddosProtectionPlan.Name
Assert-AreEqual $listRg[0].Location $ddosProtectionPlan.Location
Assert-AreEqual $listRg[0].Etag $ddosProtectionPlan.Etag

# Get all DDoS protection plans in the subscription

$listSub = Get-AzureRmDdosProtectionPlan

$ddosProtectionPlanFromList = @($listSub) | Where-Object Name -eq $ddosProtectionPlanName | Where-Object ResourceGroupName -eq $rgName
Assert-AreEqual $ddosProtectionPlan.ResourceGroupName $ddosProtectionPlanFromList.ResourceGroupName
Assert-AreEqual $ddosProtectionPlan.Name $ddosProtectionPlanFromList.Name
Assert-AreEqual $ddosProtectionPlan.Location $ddosProtectionPlanFromList.Location
Assert-AreEqual $ddosProtectionPlan.Etag $ddosProtectionPlanFromList.Etag
}
finally
{
# Cleanup
Clean-ResourceGroup $rgName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,37 @@ function Test-subnetCRUD

<#
.SYNOPSIS
Tests creating new simple virtualNetwork with DDoSProtecion parameters.
Tests the creation of a new virtual network with DDoS protection parameters.
#>
function Test-VirtualNetworkCRUDWithDDoSProtection
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$subnetName = Get-ResourceName
$ddosProtectionPlanName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
$location = Get-ProviderLocation $resourceTypeParent

try
{
# Create the resource group

$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }


# Create a DDoS Protection plan

$ddosProtectionPlan = New-AzureRmDdosProtectionPlan -Name $ddosProtectionPlanName -ResourceGroupName $rgname -Location $location

# Create the Virtual Network

$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
$actual = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -DnsServer 8.8.8.8 -Subnet $subnet -EnableDDoSProtection
$actual = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -DnsServer 8.8.8.8 -Subnet $subnet -EnableDdoSProtection -DdosProtectionPlanId $ddosProtectionPlan.Id
$expected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
Assert-AreEqual $expected.ResourceGroupName $rgname
Assert-AreEqual $expected.Name $actual.Name

Assert-AreEqual $expected.ResourceGroupName $rgname
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual $expected.Location $actual.Location
Assert-AreEqual "Succeeded" $expected.ProvisioningState
Assert-NotNull $expected.ResourceGuid
Expand All @@ -210,23 +217,35 @@ function Test-VirtualNetworkCRUDWithDDoSProtection
Assert-AreEqual $subnetName $expected.Subnets[0].Name
Assert-AreEqual "10.0.1.0/24" $expected.Subnets[0].AddressPrefix
Assert-AreEqual true $expected.EnableDDoSProtection
Assert-AreEqual $ddosProtectionPlan.Id $expected.DdosProtectionPlan.Id
Assert-AreEqual false $expected.EnableVmProtection

$expected.EnableDDoSProtection=$false

$expected.EnableDDoSProtection = $false
$expected.DdosProtectionPlan = $null
Set-AzureRmVirtualNetwork -VirtualNetwork $expected
$expected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
Assert-AreEqual false $expected.EnableDDoSProtection
Assert-AreEqual false $expected.EnableVmProtection
Assert-AreEqual $null $expected.DdosProtectionPlan

$expected.EnableVmProtection=$true
$expected.EnableVmProtection = $true
$expected.DdosProtectionPlan = New-Object Microsoft.Azure.Commands.Network.Models.PSResourceId
$expected.DdosProtectionPlan.Id = $ddosProtectionPlan.Id
Set-AzureRmVirtualNetwork -VirtualNetwork $expected
$expected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
Assert-AreEqual false $expected.EnableDDoSProtection
Assert-AreEqual true $expected.EnableVmProtection

# Delete VirtualNetwork
$delete = Remove-AzureRmvirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
Assert-AreEqual true $delete
Assert-AreEqual $ddosProtectionPlan.Id $expected.DdosProtectionPlan.Id

# Delete the virtual network

$deleteVnet = Remove-AzureRmvirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
Assert-AreEqual true $deleteVnet

# Delete the DDoS protection plan

$deleteDdosProtectionPlan = Remove-AzureRmDdosProtectionPlan -ResourceGroupName $rgname -name $ddosProtectionPlanName -PassThru
Assert-AreEqual true $deleteDdosProtectionPlan
}
finally
{
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading