Skip to content

Inbound NAT pools PowerShell changes. #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 30, 2015
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="8.2.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.10-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.11-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5715.36130-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="8.2.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.10-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.11-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -299,6 +299,12 @@
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerSet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerInboundNatPoolConfigCRUDPublicLB.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerInboundNatPoolConfigInternalLB.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkSecurityGroupTests\TestNetworkSecurityGroupCRUD.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,19 @@ public void TestLoadBalancerNicAssociationDuringCreate()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancer-NicAssociationDuringCreate");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLoadBalancerInboundNatPoolConfigInternalLB()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerInboundNatPoolConfigCRUD-InternalLB");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLoadBalancerInboundNatPoolConfigCRUDPublicLB()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerInboundNatPoolConfigCRUD-PublicLB");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1117,4 +1117,190 @@ function Test-LoadBalancer-NicAssociationDuringCreate
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Tests creating new internal Load balancer and CRUD inbound nat pools on the load balancer
#>
function Test-LoadBalancerInboundNatPoolConfigCRUD-InternalLB
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$subnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$domainNameLabel = Get-ResourceName
$lbName = Get-ResourceName
$frontendName = Get-ResourceName
$rglocation = "West US"
$resourceTypeParent = "Microsoft.Network/loadBalancers"
$location = "West US"

try
{
# Create the resource group
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}

# Create the Virtual Network
$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 -Subnet $subnet

# Create the publicip
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel

$frontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $frontendName -SubnetId $vnet.Subnets[0].Id
New-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend

$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname

# Test InboundNatPool cmdlets
$inboundNatPoolName = Get-ResourceName
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
$lb = $lb | Add-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName -FrontendIPConfigurationId $lb.FrontendIPConfigurations[0].Id -Protocol Tcp -FrontendPortRangeStart 3360 -FrontendPortRangeEnd 3362 -BackendPort 3370 | Set-AzureRmLoadBalancer

Assert-AreEqual 1 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name
Assert-AreEqual 3360 $lb.InboundNatPools[0].FrontendPortRangeStart
Assert-AreEqual 3362 $lb.InboundNatPools[0].FrontendPortRangeEnd
Assert-AreEqual 3370 $lb.InboundNatPools[0].BackendPort
Assert-AreEqual Tcp $lb.InboundNatPools[0].Protocol

$inboundNatPoolName2 = Get-ResourceName
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Add-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 -FrontendIPConfigurationId $lb.FrontendIPConfigurations[0].Id -Protocol Udp -FrontendPortRangeStart 3366 -FrontendPortRangeEnd 3368 -BackendPort 3376 | Set-AzureRmLoadBalancer

Assert-AreEqual 2 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
Assert-AreEqual 3366 $lb.InboundNatPools[1].FrontendPortRangeStart
Assert-AreEqual 3368 $lb.InboundNatPools[1].FrontendPortRangeEnd
Assert-AreEqual 3376 $lb.InboundNatPools[1].BackendPort
Assert-AreEqual Udp $lb.InboundNatPools[1].Protocol

$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Set-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 -FrontendIPConfigurationId $lb.FrontendIPConfigurations[0].Id -Protocol Tcp -FrontendPortRangeStart 3363 -FrontendPortRangeEnd 3364 -BackendPort 3373 | Set-AzureRmLoadBalancer
Assert-AreEqual 2 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
Assert-AreEqual 3363 $lb.InboundNatPools[1].FrontendPortRangeStart
Assert-AreEqual 3364 $lb.InboundNatPools[1].FrontendPortRangeEnd
Assert-AreEqual 3373 $lb.InboundNatPools[1].BackendPort
Assert-AreEqual Tcp $lb.InboundNatPools[1].Protocol


$inboundNatPoolConfig = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2
$inboundNatPoolConfigList = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig
Assert-AreEqual 2 @($inboundNatPoolConfigList).Count
Assert-AreEqual $inboundNatPoolName $inboundNatPoolConfigList[0].Name
Assert-AreEqual $inboundNatPoolName2 $inboundNatPoolConfigList[1].Name
Assert-AreEqual $inboundNatPoolConfig.Name $inboundNatPoolConfigList[1].Name

$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Remove-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 | Set-AzureRmLoadBalancer
Assert-AreEqual 1 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name

# Delete
$deleteLb = $lb | Remove-AzureRmLoadBalancer -PassThru -Force
Assert-AreEqual true $deleteLb

$list = Get-AzureRmLoadBalancer -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Tests creating new public Load balancer and CRUD inbound nat pools on the load balancer
#>
function Test-LoadBalancerInboundNatPoolConfigCRUD-PublicLB
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$subnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$domainNameLabel = Get-ResourceName
$lbName = Get-ResourceName
$frontendName = Get-ResourceName
$inboundNatPoolName = Get-ResourceName
$rglocation = "West US"
$resourceTypeParent = "Microsoft.Network/loadBalancers"
$location = "West US"

try
{
# Create the resource group
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}

# Create the publicip
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel

# Create LoadBalancer with one Inbound NAT Pool
$frontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $publicip
$inboundNatPool = New-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName -FrontendIPConfigurationId $frontend.Id -Protocol Tcp -FrontendPortRangeStart 3360 -FrontendPortRangeEnd 3362 -BackendPort 3370
$actualLb = New-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend -InboundNatPool $inboundNatPool

$expectedLb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname

# LB Verifications
Assert-AreEqual $expectedLb.ResourceGroupName $actualLb.ResourceGroupName
Assert-AreEqual $expectedLb.Name $actualLb.Name
Assert-AreEqual $expectedLb.Location $actualLb.Location
Assert-AreEqual "Succeeded" $expectedLb.ProvisioningState
Assert-NotNull $expectedLb.ResourceGuid
Assert-AreEqual 1 @($expectedLb.FrontendIPConfigurations).Count

Assert-AreEqual 1 @($expectedLb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName $expectedLb.InboundNatPools[0].Name
Assert-AreEqual 3360 $expectedLb.InboundNatPools[0].FrontendPortRangeStart
Assert-AreEqual 3362 $expectedLb.InboundNatPools[0].FrontendPortRangeEnd
Assert-AreEqual 3370 $expectedLb.InboundNatPools[0].BackendPort
Assert-AreEqual Tcp $expectedLb.InboundNatPools[0].Protocol
Assert-AreEqual $expectedLb.FrontendIPConfigurations[0].Id $expectedLb.InboundNatPools[0].FrontendIPConfiguration.Id

# Test InboundNatPool cmdlets
$inboundNatPoolName2 = Get-ResourceName
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
$lb = Add-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $lb -Name $inboundNatPoolName2 -FrontendIPConfiguration $lb.FrontendIPConfigurations[0] -Protocol Udp -FrontendPortRangeStart 3366 -FrontendPortRangeEnd 3368 -BackendPort 3376 | Set-AzureRmLoadBalancer

Assert-AreEqual 2 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
Assert-AreEqual 3366 $lb.InboundNatPools[1].FrontendPortRangeStart
Assert-AreEqual 3368 $lb.InboundNatPools[1].FrontendPortRangeEnd
Assert-AreEqual 3376 $lb.InboundNatPools[1].BackendPort
Assert-AreEqual Udp $lb.InboundNatPools[1].Protocol

$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Set-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 -FrontendIPConfigurationId $lb.FrontendIPConfigurations[0].Id -Protocol Tcp -FrontendPortRangeStart 3363 -FrontendPortRangeEnd 3364 -BackendPort 3373 | Set-AzureRmLoadBalancer
Assert-AreEqual 2 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
Assert-AreEqual 3363 $lb.InboundNatPools[1].FrontendPortRangeStart
Assert-AreEqual 3364 $lb.InboundNatPools[1].FrontendPortRangeEnd
Assert-AreEqual 3373 $lb.InboundNatPools[1].BackendPort
Assert-AreEqual Tcp $lb.InboundNatPools[1].Protocol

$inboundNatPoolConfig = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2
$inboundNatPoolConfigList = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig
Assert-AreEqual 2 @($inboundNatPoolConfigList).Count
Assert-AreEqual $inboundNatPoolName $inboundNatPoolConfigList[0].Name
Assert-AreEqual $inboundNatPoolName2 $inboundNatPoolConfigList[1].Name
Assert-AreEqual $inboundNatPoolConfig.Name $inboundNatPoolConfigList[1].Name

$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Remove-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 | Set-AzureRmLoadBalancer
Assert-AreEqual 1 @($lb.InboundNatPools).Count
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name

# Delete LB
$deleteLb = Remove-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -PassThru -Force
Assert-AreEqual true $deleteLb

$list = Get-AzureRmLoadBalancer -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading