Skip to content

Commit 3617f13

Browse files
committed
Merge pull request #1534 from kagamsft/dev
[AppGW] Adding name as parameter in path rules
2 parents 74530c4 + 9667cd3 commit 3617f13

File tree

4 files changed

+2658
-854
lines changed

4 files changed

+2658
-854
lines changed

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

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ function Test-ApplicationGatewayCRUD
2424
$resourceTypeParent = "Microsoft.Network/applicationgateways"
2525
$location = Get-ProviderLocation $resourceTypeParent
2626

27-
$rgname = "kagarg"
27+
$rgname = "rg01"
28+
$appgwName = "appgw01"
2829
$vnetName = "vnet01"
2930
$subnetName = "subnet01"
30-
$publicIpName = "publicip01" 
31+
$publicIpName = "publicip01"
3132
$gipconfigname = "gatewayip01"
32-
$fipconfigName = "frontendip01"
33+
$fipconfig01Name = "frontendip01"
34+
$fipconfig02Name = "frontendip02"
3335
$poolName = "pool01"
3436
$frontendPort01Name = "frontendport01"
3537
$frontendPort02Name = "frontendport02"
3638
$poolSetting01Name = "setting01"
3739
$poolSetting02Name = "setting02"
38-
$probeName ="probe01"
3940
$listener01Name = "listener01"
4041
$listener02Name = "listener02"
4142
$rule01Name = "rule01"
4243
$rule02Name = "rule02"
43-
$appgwName = "appgw01"
4444

4545
try
4646
{
4747
# Create the resource group
48-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "PS testing app gw"}
48+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "APPGw tag"}
4949

5050
# Create the Virtual Network
5151
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
@@ -54,31 +54,104 @@ function Test-ApplicationGatewayCRUD
5454
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
5555

5656
# Create public ip
57-
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic 
58-
 
57+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic
58+
5959
# Create application gateway configuration
6060
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $subnet
61-
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
61+
62+
$fipconfig01 = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfig01Name -PublicIPAddress $publicip
63+
$fipconfig02 = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfig02Name -Subnet $subnet
64+
6265
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
66+
6367
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
6468
$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
69+
70+
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
71+
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol Http -CookieBasedAffinity Enabled
72+
73+
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol Http -FrontendIPConfiguration $fipconfig01 -FrontendPort $fp01
74+
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Http -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp02
75+
7076
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
7177
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
78+
7279
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
7380

7481
# 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-
 
82+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku
83+
7784
# Get Application Gateway
7885
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
79-
 
80-
# Start Application Gateway
81-
Start-AzureRmApplicationGateway -ApplicationGateway $getgw
86+
87+
88+
# Add probe, request timeout, multi-hosting, URL routing to an exisitng gateway
89+
# Probe, request timeout, multi-site and URL routing are optional.
90+
$probeName = "probe01"
91+
$frontendPort03Name = "frontendport03"
92+
$poolSetting03Name = "setting03"
93+
$listener03Name = "listener03"
94+
$rule03Name = "rule03"
95+
$PathRule01Name = "pathrule01"
96+
$PathRule02Name = "pathrule02"
97+
$urlPathMapName = "urlpathmap01"
98+
99+
# Adding new frontend port
100+
$getgw = Add-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name  -Port 8888
101+
$fp = Get-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name 
102+
103+
# Add new probe
104+
$getgw = Add-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8
105+
$probe = Get-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName
106+
107+
# Add listener that has hostname. Hostname is used to have multi-site
108+
$fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -ApplicationGateway $getgw -Name $fipconfig02Name
109+
$getgw = Add-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp -HostName TestHostName
110+
$listener = Get-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name
111+
$pool = Get-AzureRmApplicationGatewayBackendAddressPool -ApplicationGateway $getgw -Name $poolName
112+
113+
# Add new BackendHttpSettings that has probe and request timeout
114+
$getgw = Add-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
115+
$poolSetting = Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name
116+
117+
# Add new URL routing
118+
$imagePathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule01Name -Paths "/image" -BackendAddressPool $pool -BackendHttpSettings $poolSetting
119+
$videoPathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule02Name -Paths "/video" -BackendAddressPool $pool -BackendHttpSettings $poolSetting
120+
$getgw = Add-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName -PathRules $videoPathRule, $imagePathRule -DefaultBackendAddressPool $pool -DefaultBackendHttpSettings $poolSetting
121+
$urlPathMap = Get-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName
122+
123+
# Add new rule with URL routing
124+
$getgw = Add-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $getgw -Name $rule03Name -RuleType PathBasedRouting -HttpListener $listener -UrlPathMap $urlPathMap
125+
126+
# Modify existing application gateway with new configuration
127+
Set-AzureRmApplicationGateway -ApplicationGateway $getgw
128+
129+
# Remove probe, request timeout, multi-site and URL routing from exiting gateway
130+
# Probe, request timeout, multi-site, URL routing are optional
131+
$getgw = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
132+
133+
# Remove probe
134+
$getgw = Remove-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName
135+
136+
# Remove URL path map
137+
$getgw = Remove-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName
138+
139+
# Modify BackendHttpSettings to remove probe and request timeout
140+
$getgw = Set-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
141+
$poolSetting = Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name
142+
143+
# Modify listener to remove hostname. Hostname is used to have multi-site.
144+
$fp = Get-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name 
145+
$fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -ApplicationGateway $getgw -Name $fipconfig02Name
146+
$getgw = Set-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp
147+
$listener = Get-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name
148+
149+
# Modify rule to remove URL rotuing
150+
$pool = Get-AzureRmApplicationGatewayBackendAddressPool -ApplicationGateway $getgw -Name $poolName
151+
$getgw = Set-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $getgw -Name $rule03Name -RuleType basic -HttpListener $listener -BackendHttpSettings $poolSetting -BackendAddressPool $pool
152+
153+
# Modify existing application gateway with new configuration
154+
Set-AzureRmApplicationGateway -ApplicationGateway $getgw
82155

83156
# Stop Application Gateway
84157
Stop-AzureRmApplicationGateway -ApplicationGateway $getgw

0 commit comments

Comments
 (0)