Skip to content

Commit cbd9c6d

Browse files
committed
Merge pull request Azure#973 from ankurchoubeymsft/dev
Inbound NAT pools PowerShell changes.
2 parents 5f2924a + e6cb77a commit cbd9c6d

27 files changed

+6091
-29
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74-
<SpecificVersion>False</SpecificVersion>
75-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
75+
<Private>True</Private>
7676
</Reference>
7777
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7878
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

src/ResourceManager/Compute/Commands.Compute.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Compute" version="8.2.0" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Network" version="2.0.10-preview" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Network" version="2.0.11-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Test.Framework" version="1.0.5715.36130-prerelease" targetFramework="net45" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
<Private>True</Private>
8686
</Reference>
8787
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
88-
<SpecificVersion>False</SpecificVersion>
89-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
88+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
89+
<Private>True</Private>
9090
</Reference>
9191
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9292
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

src/ResourceManager/Compute/Commands.Compute/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Compute" version="8.2.0" targetFramework="net45" />
13-
<package id="Microsoft.Azure.Management.Network" version="2.0.10-preview" targetFramework="net45" />
13+
<package id="Microsoft.Azure.Management.Network" version="2.0.11-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
1515
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1616
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70-
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.10-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
70+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.11-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
71+
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7474
<SpecificVersion>False</SpecificVersion>
@@ -299,6 +299,12 @@
299299
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerSet.json">
300300
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
301301
</None>
302+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerInboundNatPoolConfigCRUDPublicLB.json">
303+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
304+
</None>
305+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.LoadBalancerTests\TestLoadBalancerInboundNatPoolConfigInternalLB.json">
306+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
307+
</None>
302308
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkSecurityGroupTests\TestNetworkSecurityGroupCRUD.json">
303309
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
304310
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/LoadBalancerTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,19 @@ public void TestLoadBalancerNicAssociationDuringCreate()
102102
{
103103
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancer-NicAssociationDuringCreate");
104104
}
105+
106+
[Fact]
107+
[Trait(Category.AcceptanceType, Category.CheckIn)]
108+
public void TestLoadBalancerInboundNatPoolConfigInternalLB()
109+
{
110+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerInboundNatPoolConfigCRUD-InternalLB");
111+
}
112+
113+
[Fact]
114+
[Trait(Category.AcceptanceType, Category.CheckIn)]
115+
public void TestLoadBalancerInboundNatPoolConfigCRUDPublicLB()
116+
{
117+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerInboundNatPoolConfigCRUD-PublicLB");
118+
}
105119
}
106120
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/LoadBalancerTests.ps1

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,4 +1117,190 @@ function Test-LoadBalancer-NicAssociationDuringCreate
11171117
# Cleanup
11181118
Clean-ResourceGroup $rgname
11191119
}
1120+
}
1121+
1122+
<#
1123+
.SYNOPSIS
1124+
Tests creating new internal Load balancer and CRUD inbound nat pools on the load balancer
1125+
#>
1126+
function Test-LoadBalancerInboundNatPoolConfigCRUD-InternalLB
1127+
{
1128+
# Setup
1129+
$rgname = Get-ResourceGroupName
1130+
$vnetName = Get-ResourceName
1131+
$subnetName = Get-ResourceName
1132+
$publicIpName = Get-ResourceName
1133+
$domainNameLabel = Get-ResourceName
1134+
$lbName = Get-ResourceName
1135+
$frontendName = Get-ResourceName
1136+
$rglocation = "West US"
1137+
$resourceTypeParent = "Microsoft.Network/loadBalancers"
1138+
$location = "West US"
1139+
1140+
try
1141+
{
1142+
# Create the resource group
1143+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
1144+
1145+
# Create the Virtual Network
1146+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
1147+
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1148+
1149+
# Create the publicip
1150+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
1151+
1152+
$frontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $frontendName -SubnetId $vnet.Subnets[0].Id
1153+
New-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend
1154+
1155+
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
1156+
1157+
# Test InboundNatPool cmdlets
1158+
$inboundNatPoolName = Get-ResourceName
1159+
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
1160+
$lb = $lb | Add-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName -FrontendIPConfigurationId $lb.FrontendIPConfigurations[0].Id -Protocol Tcp -FrontendPortRangeStart 3360 -FrontendPortRangeEnd 3362 -BackendPort 3370 | Set-AzureRmLoadBalancer
1161+
1162+
Assert-AreEqual 1 @($lb.InboundNatPools).Count
1163+
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name
1164+
Assert-AreEqual 3360 $lb.InboundNatPools[0].FrontendPortRangeStart
1165+
Assert-AreEqual 3362 $lb.InboundNatPools[0].FrontendPortRangeEnd
1166+
Assert-AreEqual 3370 $lb.InboundNatPools[0].BackendPort
1167+
Assert-AreEqual Tcp $lb.InboundNatPools[0].Protocol
1168+
1169+
$inboundNatPoolName2 = Get-ResourceName
1170+
$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
1171+
1172+
Assert-AreEqual 2 @($lb.InboundNatPools).Count
1173+
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
1174+
Assert-AreEqual 3366 $lb.InboundNatPools[1].FrontendPortRangeStart
1175+
Assert-AreEqual 3368 $lb.InboundNatPools[1].FrontendPortRangeEnd
1176+
Assert-AreEqual 3376 $lb.InboundNatPools[1].BackendPort
1177+
Assert-AreEqual Udp $lb.InboundNatPools[1].Protocol
1178+
1179+
$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
1180+
Assert-AreEqual 2 @($lb.InboundNatPools).Count
1181+
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
1182+
Assert-AreEqual 3363 $lb.InboundNatPools[1].FrontendPortRangeStart
1183+
Assert-AreEqual 3364 $lb.InboundNatPools[1].FrontendPortRangeEnd
1184+
Assert-AreEqual 3373 $lb.InboundNatPools[1].BackendPort
1185+
Assert-AreEqual Tcp $lb.InboundNatPools[1].Protocol
1186+
1187+
1188+
$inboundNatPoolConfig = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2
1189+
$inboundNatPoolConfigList = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig
1190+
Assert-AreEqual 2 @($inboundNatPoolConfigList).Count
1191+
Assert-AreEqual $inboundNatPoolName $inboundNatPoolConfigList[0].Name
1192+
Assert-AreEqual $inboundNatPoolName2 $inboundNatPoolConfigList[1].Name
1193+
Assert-AreEqual $inboundNatPoolConfig.Name $inboundNatPoolConfigList[1].Name
1194+
1195+
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Remove-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 | Set-AzureRmLoadBalancer
1196+
Assert-AreEqual 1 @($lb.InboundNatPools).Count
1197+
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name
1198+
1199+
# Delete
1200+
$deleteLb = $lb | Remove-AzureRmLoadBalancer -PassThru -Force
1201+
Assert-AreEqual true $deleteLb
1202+
1203+
$list = Get-AzureRmLoadBalancer -ResourceGroupName $rgname
1204+
Assert-AreEqual 0 @($list).Count
1205+
}
1206+
finally
1207+
{
1208+
# Cleanup
1209+
Clean-ResourceGroup $rgname
1210+
}
1211+
}
1212+
1213+
<#
1214+
.SYNOPSIS
1215+
Tests creating new public Load balancer and CRUD inbound nat pools on the load balancer
1216+
#>
1217+
function Test-LoadBalancerInboundNatPoolConfigCRUD-PublicLB
1218+
{
1219+
# Setup
1220+
$rgname = Get-ResourceGroupName
1221+
$vnetName = Get-ResourceName
1222+
$subnetName = Get-ResourceName
1223+
$publicIpName = Get-ResourceName
1224+
$domainNameLabel = Get-ResourceName
1225+
$lbName = Get-ResourceName
1226+
$frontendName = Get-ResourceName
1227+
$inboundNatPoolName = Get-ResourceName
1228+
$rglocation = "West US"
1229+
$resourceTypeParent = "Microsoft.Network/loadBalancers"
1230+
$location = "West US"
1231+
1232+
try
1233+
{
1234+
# Create the resource group
1235+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
1236+
1237+
# Create the publicip
1238+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
1239+
1240+
# Create LoadBalancer with one Inbound NAT Pool
1241+
$frontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $publicip
1242+
$inboundNatPool = New-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName -FrontendIPConfigurationId $frontend.Id -Protocol Tcp -FrontendPortRangeStart 3360 -FrontendPortRangeEnd 3362 -BackendPort 3370
1243+
$actualLb = New-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend -InboundNatPool $inboundNatPool
1244+
1245+
$expectedLb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
1246+
1247+
# LB Verifications
1248+
Assert-AreEqual $expectedLb.ResourceGroupName $actualLb.ResourceGroupName
1249+
Assert-AreEqual $expectedLb.Name $actualLb.Name
1250+
Assert-AreEqual $expectedLb.Location $actualLb.Location
1251+
Assert-AreEqual "Succeeded" $expectedLb.ProvisioningState
1252+
Assert-NotNull $expectedLb.ResourceGuid
1253+
Assert-AreEqual 1 @($expectedLb.FrontendIPConfigurations).Count
1254+
1255+
Assert-AreEqual 1 @($expectedLb.InboundNatPools).Count
1256+
Assert-AreEqual $inboundNatPoolName $expectedLb.InboundNatPools[0].Name
1257+
Assert-AreEqual 3360 $expectedLb.InboundNatPools[0].FrontendPortRangeStart
1258+
Assert-AreEqual 3362 $expectedLb.InboundNatPools[0].FrontendPortRangeEnd
1259+
Assert-AreEqual 3370 $expectedLb.InboundNatPools[0].BackendPort
1260+
Assert-AreEqual Tcp $expectedLb.InboundNatPools[0].Protocol
1261+
Assert-AreEqual $expectedLb.FrontendIPConfigurations[0].Id $expectedLb.InboundNatPools[0].FrontendIPConfiguration.Id
1262+
1263+
# Test InboundNatPool cmdlets
1264+
$inboundNatPoolName2 = Get-ResourceName
1265+
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
1266+
$lb = Add-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $lb -Name $inboundNatPoolName2 -FrontendIPConfiguration $lb.FrontendIPConfigurations[0] -Protocol Udp -FrontendPortRangeStart 3366 -FrontendPortRangeEnd 3368 -BackendPort 3376 | Set-AzureRmLoadBalancer
1267+
1268+
Assert-AreEqual 2 @($lb.InboundNatPools).Count
1269+
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
1270+
Assert-AreEqual 3366 $lb.InboundNatPools[1].FrontendPortRangeStart
1271+
Assert-AreEqual 3368 $lb.InboundNatPools[1].FrontendPortRangeEnd
1272+
Assert-AreEqual 3376 $lb.InboundNatPools[1].BackendPort
1273+
Assert-AreEqual Udp $lb.InboundNatPools[1].Protocol
1274+
1275+
$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
1276+
Assert-AreEqual 2 @($lb.InboundNatPools).Count
1277+
Assert-AreEqual $inboundNatPoolName2 $lb.InboundNatPools[1].Name
1278+
Assert-AreEqual 3363 $lb.InboundNatPools[1].FrontendPortRangeStart
1279+
Assert-AreEqual 3364 $lb.InboundNatPools[1].FrontendPortRangeEnd
1280+
Assert-AreEqual 3373 $lb.InboundNatPools[1].BackendPort
1281+
Assert-AreEqual Tcp $lb.InboundNatPools[1].Protocol
1282+
1283+
$inboundNatPoolConfig = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2
1284+
$inboundNatPoolConfigList = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzureRmLoadBalancerInboundNatPoolConfig
1285+
Assert-AreEqual 2 @($inboundNatPoolConfigList).Count
1286+
Assert-AreEqual $inboundNatPoolName $inboundNatPoolConfigList[0].Name
1287+
Assert-AreEqual $inboundNatPoolName2 $inboundNatPoolConfigList[1].Name
1288+
Assert-AreEqual $inboundNatPoolConfig.Name $inboundNatPoolConfigList[1].Name
1289+
1290+
$lb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname | Remove-AzureRmLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName2 | Set-AzureRmLoadBalancer
1291+
Assert-AreEqual 1 @($lb.InboundNatPools).Count
1292+
Assert-AreEqual $inboundNatPoolName $lb.InboundNatPools[0].Name
1293+
1294+
# Delete LB
1295+
$deleteLb = Remove-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname -PassThru -Force
1296+
Assert-AreEqual true $deleteLb
1297+
1298+
$list = Get-AzureRmLoadBalancer -ResourceGroupName $rgname
1299+
Assert-AreEqual 0 @($list).Count
1300+
}
1301+
finally
1302+
{
1303+
# Cleanup
1304+
Clean-ResourceGroup $rgname
1305+
}
11201306
}

0 commit comments

Comments
 (0)