Skip to content

Commit 47a3828

Browse files
committed
Merge pull request #1433 from kagamsft/dev
[AppGW] Adding probe, multisite and URl routing support
2 parents 2156f2c + 47cc609 commit 47a3828

File tree

40 files changed

+2270
-5044
lines changed

40 files changed

+2270
-5044
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
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.9.1.0\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
74-
<Reference Include="Microsoft.Azure.Management.Network">
75-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
74+
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
7676
<Private>True</Private>
7777
</Reference>
7878
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

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="9.1.0" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Network" version="3.0.2-preview" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.4.0-preview" targetFramework="net45" />

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,13 @@
8585
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.9.1.0\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
8686
<Private>True</Private>
8787
</Reference>
88-
<Reference Include="Microsoft.Azure.Management.Network">
89-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
88+
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
89+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
90+
<Private>True</Private>
9091
</Reference>
9192
<Reference Include="Microsoft.Azure.Management.Storage">
9293
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.3.0.0\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
9394
</Reference>
94-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
95-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\dotnet\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
96-
</Reference>
9795
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9896
<SpecificVersion>False</SpecificVersion>
9997
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
@@ -114,14 +112,18 @@
114112
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
115113
<Private>True</Private>
116114
</Reference>
117-
<Reference Include="Microsoft.Rest.ClientRuntime">
115+
<Reference Include="Microsoft.Rest.ClientRuntime">
118116
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.4.1\lib\dotnet\Microsoft.Rest.ClientRuntime.dll</HintPath>
119117
<Private>True</Private>
120118
</Reference>
121119
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
122120
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\dotnet\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
123121
<Private>True</Private>
124122
</Reference>
123+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
124+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\portable-net45+win8+wpa81\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
125+
<Private>True</Private>
126+
</Reference>
125127
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
126128
<SpecificVersion>False</SpecificVersion>
127129
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.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="9.1.0" targetFramework="net45" />
13-
<package id="Microsoft.Azure.Management.Network" version="3.0.2-preview" targetFramework="net45" />
13+
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
1515
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1616
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
<Reference Include="Microsoft.Azure.Management.Authorization">
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6868
</Reference>
69-
<Reference Include="Microsoft.Azure.Management.Network">
70-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.3-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
69+
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.ResourceManager">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Commands.Network.Test.ScenarioTests
2020
{
2121
public class ApplicationGatewayTests : RMTestBase
2222
{
23-
[Fact(Skip = "Rerecord tests")]
23+
[Fact]
2424
[Trait(Category.AcceptanceType, Category.CheckIn)]
2525
public void TestApplicationGatewayCRUD()
2626
{

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

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,70 @@ function Test-ApplicationGatewayCRUD
2020
{
2121
# Setup
2222

23-
$rgname = Get-ResourceGroupName
24-
$rname = Get-ResourceName
25-
$domainNameLabel = Get-ResourceName
26-
$vnetName = Get-ResourceName
27-
$publicIpName = Get-ResourceName
28-
$vnetGatewayConfigName = Get-ResourceName
2923
$rglocation = Get-ProviderLocation ResourceManagement
3024
$resourceTypeParent = "Microsoft.Network/applicationgateways"
3125
$location = Get-ProviderLocation $resourceTypeParent
3226

33-
$gipconfigname = Get-ResourceName
34-
$fipconfigName = Get-ResourceName
35-
$poolName = Get-ResourceName
36-
$poolSettingName = Get-ResourceName
37-
$frontendPortName = Get-ResourceName
38-
$listenerName = Get-ResourceName
39-
$ruleName = Get-ResourceName
40-
$appgwName = Get-ResourceName
27+
$rgname = "kagarg"
28+
$vnetName = "vnet01"
29+
$subnetName = "subnet01"
30+
$publicIpName = "publicip01" 
31+
$gipconfigname = "gatewayip01"
32+
$fipconfigName = "frontendip01"
33+
$poolName = "pool01"
34+
$frontendPort01Name = "frontendport01"
35+
$frontendPort02Name = "frontendport02"
36+
$poolSetting01Name = "setting01"
37+
$poolSetting02Name = "setting02"
38+
$probeName ="probe01"
39+
$listener01Name = "listener01"
40+
$listener02Name = "listener02"
41+
$rule01Name = "rule01"
42+
$rule02Name = "rule02"
43+
$appgwName = "appgw01"
4144

4245
try
4346
{
4447
# Create the resource group
45-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
46-
48+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "PS testing app gw"}
49+
      
4750
# Create the Virtual Network
48-
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
51+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
4952
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
5053
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
51-
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
52-
53-
# Create the Application Gateway
54+
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
55+
 
56+
# Create public ip
57+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic 
58+
 
59+
# Create application gateway configuration
5460
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $subnet
55-
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
56-
$poolSetting = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSettingName -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled
57-
$fp = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPortName -Port 80
5861
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
59-
$listener = New-AzureRmApplicationGatewayHttpListener -Name $listenerName -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp
60-
$rule = New-AzureRmApplicationGatewayRequestRoutingRule -Name $ruleName -RuleType basic -BackendHttpSettings $poolSetting -HttpListener $listener -BackendAddressPool $pool
62+
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
63+
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
64+
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name  -Port 8080
65+
$probe = New-AzureRmApplicationGatewayProbeConfig -Name $probeName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8
66+
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
67+
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled
68+
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp01
69+
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp02
70+
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
71+
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
6172
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
6273

63-
$actual = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp -HttpListeners $listener -RequestRoutingRules $rule -Sku $sku
64-
$expected = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
65-
Compare-AzureRmApplicationGateway $actual $expected
66-
67-
Stop-AzureRmApplicationGateway -ApplicationGateway $expected
74+
# Create Application Gateway
75+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -Probes $probe -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku
76+
 
77+
# Get Application Gateway
78+
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
79+
 
80+
# Start Application Gateway
81+
Start-AzureRmApplicationGateway -ApplicationGateway $getgw
82+
83+
# Stop Application Gateway
84+
Stop-AzureRmApplicationGateway -ApplicationGateway $getgw
85+
 
86+
# Delete Application Gateway
6887
Remove-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
6988
}
7089
finally

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ApplicationGatewayTests/TestApplicationGatewayCRUD.json

Lines changed: 1042 additions & 4989 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
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" />
10-
<package id="Microsoft.Azure.Management.Network" version="3.0.3-preview" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.4.0-preview" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network/ApplicationGateway/ApplicationGatewayChildResourceHelper.cs

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,29 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
114114
}
115115
}
116116

117+
// Normalize Probe
118+
if (applicationGateway.Probes != null)
119+
{
120+
foreach (var probe in applicationGateway.Probes)
121+
{
122+
probe.Id = string.Empty;
123+
}
124+
}
125+
117126
// Normalize BackendHttpSettings
118127
if (applicationGateway.BackendHttpSettingsCollection != null)
119128
{
120129
foreach (var backendHttpSettings in applicationGateway.BackendHttpSettingsCollection)
121130
{
122131
backendHttpSettings.Id = string.Empty;
132+
133+
if (null != backendHttpSettings.Probe)
134+
{
135+
backendHttpSettings.Probe.Id = NormalizeApplicationGatewayNameChildResourceIds(
136+
backendHttpSettings.Probe.Id,
137+
applicationGateway.ResourceGroupName,
138+
applicationGateway.Name);
139+
}
123140
}
124141
}
125142

@@ -153,6 +170,38 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
153170
}
154171
}
155172

173+
// Normalize UrlPathMap
174+
if (applicationGateway.UrlPathMaps != null)
175+
{
176+
foreach (var urlPathMap in applicationGateway.UrlPathMaps)
177+
{
178+
urlPathMap.Id = string.Empty;
179+
180+
urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
181+
urlPathMap.DefaultBackendAddressPool.Id,
182+
applicationGateway.ResourceGroupName,
183+
applicationGateway.Name);
184+
185+
urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
186+
urlPathMap.DefaultBackendHttpSettings.Id,
187+
applicationGateway.ResourceGroupName,
188+
applicationGateway.Name);
189+
190+
foreach (var pathRule in urlPathMap.PathRules)
191+
{
192+
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
193+
pathRule.BackendAddressPool.Id,
194+
applicationGateway.ResourceGroupName,
195+
applicationGateway.Name);
196+
197+
pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
198+
pathRule.BackendHttpSettings.Id,
199+
applicationGateway.ResourceGroupName,
200+
applicationGateway.Name);
201+
}
202+
}
203+
}
204+
156205
// Normalize RequestRoutingRule
157206
if (applicationGateway.RequestRoutingRules != null)
158207
{
@@ -165,15 +214,29 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
165214
applicationGateway.ResourceGroupName,
166215
applicationGateway.Name);
167216

168-
requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
169-
requestRoutingRule.BackendAddressPool.Id,
217+
if (null != requestRoutingRule.BackendAddressPool)
218+
{
219+
requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
220+
requestRoutingRule.BackendAddressPool.Id,
221+
applicationGateway.ResourceGroupName,
222+
applicationGateway.Name);
223+
}
224+
225+
if (null != requestRoutingRule.BackendHttpSettings)
226+
{
227+
requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
228+
requestRoutingRule.BackendHttpSettings.Id,
170229
applicationGateway.ResourceGroupName,
171230
applicationGateway.Name);
231+
}
172232

173-
requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
174-
requestRoutingRule.BackendHttpSettings.Id,
233+
if (null != requestRoutingRule.UrlPathMap)
234+
{
235+
requestRoutingRule.UrlPathMap.Id = NormalizeApplicationGatewayNameChildResourceIds(
236+
requestRoutingRule.UrlPathMap.Id,
175237
applicationGateway.ResourceGroupName,
176238
applicationGateway.Name);
239+
}
177240
}
178241
}
179242
}

0 commit comments

Comments
 (0)