@@ -28,46 +28,34 @@ function Test-ApplicationGatewayCRUD
28
28
$appgwName = " appgw01"
29
29
$vnetName = " vnet01"
30
30
$subnetName = " subnet01"
31
- $publicIpName = " publicip01"
32
- $certName = " cert01"
31
+ $publicIpName = " publicip01"
33
32
$gipconfigname = " gatewayip01"
34
33
$fipconfig01Name = " frontendip01"
35
34
$fipconfig02Name = " frontendip02"
36
35
$poolName = " pool01"
37
36
$frontendPort01Name = " frontendport01"
38
37
$frontendPort02Name = " frontendport02"
39
- $frontendPort03Name = " frontendport03"
40
38
$poolSetting01Name = " setting01"
41
39
$poolSetting02Name = " setting02"
42
- $poolSetting03Name = " setting03"
43
- $probeName = " probe01"
44
40
$listener01Name = " listener01"
45
41
$listener02Name = " listener02"
46
- $listener03Name = " listener03"
47
42
$rule01Name = " rule01"
48
43
$rule02Name = " rule02"
49
- $rule03Name = " rule03"
50
- $PathRule01Name = " pathrule01"
51
- $PathRule02Name = " pathrule02"
52
- $urlPathMapName = " urlpathmap01"
53
44
54
45
try
55
46
{
56
47
# Create the resource group
57
- $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 " }
58
49
59
50
# Create the Virtual Network
60
51
$subnet = New-AzureRmVirtualNetworkSubnetConfig - Name $subnetName - AddressPrefix 10.0 .0.0 / 24
61
52
$vnet = New-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname - Location $location - AddressPrefix 10.0 .0.0 / 16 - Subnet $subnet
62
53
$vnet = Get-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname
63
54
$subnet = Get-AzureRmVirtualNetworkSubnetConfig - Name $subnetName - VirtualNetwork $vnet
64
-
55
+
65
56
# Create public ip
66
57
$publicip = New-AzureRmPublicIpAddress - ResourceGroupName $rgname - name $publicIpName - location $location - AllocationMethod Dynamic
67
58
68
- # Create certificate
69
- $cert = New-AzureRmApplicationGatewaySslCertificate - Name $certName - CertificateFile D:\AppGWe2eTest\GW5000.pfx - Password 1234
70
-
71
59
# Create application gateway configuration
72
60
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration - Name $gipconfigname - Subnet $subnet
73
61
@@ -76,41 +64,98 @@ function Test-ApplicationGatewayCRUD
76
64
77
65
$pool = New-AzureRmApplicationGatewayBackendAddressPool - Name $poolName - BackendIPAddresses 1.1 .1.1 , 2.2 .2.2 , 3.3 .3.3
78
66
79
- $fp01 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort01Name - Port 80
80
- $fp02 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort02Name - Port 8080
81
- $fp03 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort03Name - Port 443
67
+ $fp01 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort01Name - Port 80
68
+ $fp02 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort02Name - Port 8080
82
69
83
- $probe = New-AzureRmApplicationGatewayProbeConfig - Name $probeName - Protocol Http - HostName " probe.com" - Path " /path/path.htm" - Interval 89 - Timeout 88 - UnhealthyThreshold 8
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
70
+ $poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings - Name $poolSetting01Name - Port 80 - Protocol Http - CookieBasedAffinity Disabled
71
+ $poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings - Name $poolSetting02Name - Port 80 - Protocol Http - CookieBasedAffinity Enabled
87
72
88
73
$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
74
+ $listener02 = New-AzureRmApplicationGatewayHttpListener - Name $listener02Name - Protocol Http - FrontendIPConfiguration $fipconfig02 - FrontendPort $fp02
95
75
96
76
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule - Name $rule01Name - RuleType basic - BackendHttpSettings $poolSetting01 - HttpListener $listener01 - BackendAddressPool $pool
97
77
$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
78
100
79
$sku = New-AzureRmApplicationGatewaySku - Name Standard_Small - Tier Standard - Capacity 2
101
80
102
81
# Create Application Gateway
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
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
104
83
105
84
# Get Application Gateway
106
- $getgw = Get-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname
107
-
108
- # Start Application Gateway
109
- Start-AzureRmApplicationGateway - ApplicationGateway $getgw
85
+ $getgw = Get-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname
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
110
155
111
156
# Stop Application Gateway
112
157
Stop-AzureRmApplicationGateway - ApplicationGateway $getgw
113
-
158
+
114
159
# Delete Application Gateway
115
160
Remove-AzureRmApplicationGateway - Name $appgwName - ResourceGroupName $rgname - Force
116
161
}
0 commit comments