@@ -24,28 +24,28 @@ 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"
31
32
$gipconfigname = " gatewayip01"
32
- $fipconfigName = " frontendip01"
33
+ $fipconfig01Name = " frontendip01"
34
+ $fipconfig02Name = " frontendip02"
33
35
$poolName = " pool01"
34
36
$frontendPort01Name = " frontendport01"
35
37
$frontendPort02Name = " frontendport02"
36
38
$poolSetting01Name = " setting01"
37
39
$poolSetting02Name = " setting02"
38
- $probeName = " probe01"
39
40
$listener01Name = " listener01"
40
41
$listener02Name = " listener02"
41
42
$rule01Name = " rule01"
42
43
$rule02Name = " rule02"
43
- $appgwName = " appgw01"
44
44
45
45
try
46
46
{
47
47
# 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 " }
49
49
50
50
# Create the Virtual Network
51
51
$subnet = New-AzureRmVirtualNetworkSubnetConfig - Name $subnetName - AddressPrefix 10.0 .0.0 / 24
@@ -54,31 +54,104 @@ function Test-ApplicationGatewayCRUD
54
54
$subnet = Get-AzureRmVirtualNetworkSubnetConfig - Name $subnetName - VirtualNetwork $vnet
55
55
56
56
# 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
+
59
59
# Create application gateway configuration
60
60
$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
+
62
65
$pool = New-AzureRmApplicationGatewayBackendAddressPool - Name $poolName - BackendIPAddresses 1.1 .1.1 , 2.2 .2.2 , 3.3 .3.3
66
+
63
67
$fp01 = New-AzureRmApplicationGatewayFrontendPort - Name $frontendPort01Name - Port 80
64
68
$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
+
70
76
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule - Name $rule01Name - RuleType basic - BackendHttpSettings $poolSetting01 - HttpListener $listener01 - BackendAddressPool $pool
71
77
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule - Name $rule02Name - RuleType basic - BackendHttpSettings $poolSetting02 - HttpListener $listener02 - BackendAddressPool $pool
78
+
72
79
$sku = New-AzureRmApplicationGatewaySku - Name Standard_Small - Tier Standard - Capacity 2
73
80
74
81
# 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
+
77
84
# Get Application Gateway
78
85
$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
82
155
83
156
# Stop Application Gateway
84
157
Stop-AzureRmApplicationGateway - ApplicationGateway $getgw
0 commit comments