Skip to content

Commit 5ece712

Browse files
author
unknown
committed
[AppGW] Adding name as parameter in path rules
1 parent 47cc609 commit 5ece712

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

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

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,32 @@ 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"
32+
$certName = "cert01"
3133
$gipconfigname = "gatewayip01"
32-
$fipconfigName = "frontendip01"
34+
$fipconfig01Name = "frontendip01"
35+
$fipconfig02Name = "frontendip02"
3336
$poolName = "pool01"
3437
$frontendPort01Name = "frontendport01"
3538
$frontendPort02Name = "frontendport02"
39+
$frontendPort03Name = "frontendport03"
3640
$poolSetting01Name = "setting01"
3741
$poolSetting02Name = "setting02"
42+
$poolSetting03Name = "setting03"
3843
$probeName ="probe01"
3944
$listener01Name = "listener01"
4045
$listener02Name = "listener02"
46+
$listener03Name = "listener03"
4147
$rule01Name = "rule01"
4248
$rule02Name = "rule02"
43-
$appgwName = "appgw01"
49+
$rule03Name = "rule03"
50+
$PathRule01Name = "pathrule01"
51+
$PathRule02Name = "pathrule02"
52+
$urlPathMapName = "urlpathmap01"
4453

4554
try
4655
{
@@ -52,37 +61,56 @@ function Test-ApplicationGatewayCRUD
5261
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
5362
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
5463
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
55-
 
64+
5665
# Create public ip
57-
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic 
58-
 
66+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic
67+
68+
# Create certificate
69+
$cert = New-AzureRmApplicationGatewaySslCertificate -Name $certName -CertificateFile D:\AppGWe2eTest\GW5000.pfx -Password 1234
70+
5971
# Create application gateway configuration
6072
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $subnet
61-
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
73+
74+
$fipconfig01 = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfig01Name -PublicIPAddress $publicip
75+
$fipconfig02 = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfig02Name -Subnet $subnet
76+
6277
$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
78+
79+
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name -Port 80
80+
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name -Port 8080
81+
$fp03 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort03Name -Port 443
82+
6583
$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
84+
85+
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
86+
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
87+
88+
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol Http -FrontendIPConfiguration $fipconfig01 -FrontendPort $fp01
89+
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Https -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp02 -SslCertificate $cert
90+
$listener03 = New-AzureRmApplicationGatewayHttpListener -Name $listener03Name -Protocol Https -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp03 -SslCertificate $cert -HostName TestHostName -RequireServerNameIndication true
91+
92+
$imagePathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule01Name -Paths "/image" -BackendAddressPool $pool -BackendHttpSettings $poolSetting02
93+
$videoPathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule02Name -Paths "/video" -BackendAddressPool $pool -BackendHttpSettings $poolSetting02
94+
$urlPathMap = New-AzureRmApplicationGatewayUrlPathMapConfig -Name $urlPathMapName -PathRules $videoPathRule, $imagePathRule -DefaultBackendAddressPool $pool -DefaultBackendHttpSettings $poolSetting02
95+
7096
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
7197
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
98+
$rule03 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule03Name -RuleType PathBasedRouting -HttpListener $listener03 -UrlPathMap $urlPathMap
99+
72100
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
73101

74102
# 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-
 
103+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -Probes $probe -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02 -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02, $fp03 -SslCertificates $cert -HttpListeners $listener01, $listener02, $listener03 -UrlPathMaps $urlPathMap -RequestRoutingRules $rule01, $rule02, $rule03 -Sku $sku
104+
77105
# Get Application Gateway
78-
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
79-
 
106+
$getgw = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
107+
80108
# Start Application Gateway
81109
Start-AzureRmApplicationGateway -ApplicationGateway $getgw
82110

83111
# Stop Application Gateway
84112
Stop-AzureRmApplicationGateway -ApplicationGateway $getgw
85-
 
113+
86114
# Delete Application Gateway
87115
Remove-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
88116
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/PathRule/AzureApplicationGatewayPathRuleConfigBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace Microsoft.Azure.Commands.Network
2121
{
2222
public class AzureApplicationGatewayPathRuleConfigBase : NetworkBaseCmdlet
2323
{
24+
[Parameter(
25+
Mandatory = true,
26+
HelpMessage = "Name of the path rule")]
27+
[ValidateNotNullOrEmpty]
28+
public string Name { get; set; }
29+
2430
[Parameter(
2531
Mandatory = true,
2632
HelpMessage = "List of URL paths")]
@@ -72,6 +78,7 @@ public PSApplicationGatewayPathRule NewObject()
7278
{
7379
var pathRule = new PSApplicationGatewayPathRule();
7480

81+
pathRule.Name = this.Name;
7582
pathRule.Paths = this.Paths;
7683

7784
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))

src/ResourceManager/Network/Commands.Network/Models/PSApplicationGatewayPathRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Azure.Commands.Network.Models
1717
{
1818
using System.Collections.Generic;
1919
using Newtonsoft.Json;
20-
public class PSApplicationGatewayPathRule
20+
public class PSApplicationGatewayPathRule : PSChildResource
2121
{
2222
public List<string> Paths { get; set; }
2323
public PSResourceId BackendAddressPool { get; set; }

0 commit comments

Comments
 (0)