@@ -24,23 +24,32 @@ function Test-ApplicationGatewayCRUD
24
24
$resourceTypeParent = " Microsoft.Network/applicationgateways"
25
25
$location = Get-ProviderLocation $resourceTypeParent
26
26
27
- $rgname = " kagarg"
27
+ $rgname = " rg01"
28
+ $appgwName = " appgw01"
28
29
$vnetName = " vnet01"
29
30
$subnetName = " subnet01"
30
- $publicIpName = " publicip01"
31
+ $publicIpName = " publicip01"
32
+ $certName = " cert01"
31
33
$gipconfigname = " gatewayip01"
32
- $fipconfigName = " frontendip01"
34
+ $fipconfig01Name = " frontendip01"
35
+ $fipconfig02Name = " frontendip02"
33
36
$poolName = " pool01"
34
37
$frontendPort01Name = " frontendport01"
35
38
$frontendPort02Name = " frontendport02"
39
+ $frontendPort03Name = " frontendport03"
36
40
$poolSetting01Name = " setting01"
37
41
$poolSetting02Name = " setting02"
42
+ $poolSetting03Name = " setting03"
38
43
$probeName = " probe01"
39
44
$listener01Name = " listener01"
40
45
$listener02Name = " listener02"
46
+ $listener03Name = " listener03"
41
47
$rule01Name = " rule01"
42
48
$rule02Name = " rule02"
43
- $appgwName = " appgw01"
49
+ $rule03Name = " rule03"
50
+ $PathRule01Name = " pathrule01"
51
+ $PathRule02Name = " pathrule02"
52
+ $urlPathMapName = " urlpathmap01"
44
53
45
54
try
46
55
{
@@ -52,37 +61,56 @@ function Test-ApplicationGatewayCRUD
52
61
$vnet = New-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname - Location $location - AddressPrefix 10.0 .0.0 / 16 - Subnet $subnet
53
62
$vnet = Get-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname
54
63
$subnet = Get-AzureRmVirtualNetworkSubnetConfig - Name $subnetName - VirtualNetwork $vnet
55
-
64
+
56
65
# 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
+
59
71
# Create application gateway configuration
60
72
$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
+
62
77
$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
+
65
83
$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
+
70
96
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule - Name $rule01Name - RuleType basic - BackendHttpSettings $poolSetting01 - HttpListener $listener01 - BackendAddressPool $pool
71
97
$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
+
72
100
$sku = New-AzureRmApplicationGatewaySku - Name Standard_Small - Tier Standard - Capacity 2
73
101
74
102
# 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
+
77
105
# Get Application Gateway
78
- $getgw = Get-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname
79
-
106
+ $getgw = Get-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname
107
+
80
108
# Start Application Gateway
81
109
Start-AzureRmApplicationGateway - ApplicationGateway $getgw
82
110
83
111
# Stop Application Gateway
84
112
Stop-AzureRmApplicationGateway - ApplicationGateway $getgw
85
-
113
+
86
114
# Delete Application Gateway
87
115
Remove-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname - Force
88
116
}
0 commit comments