You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Azure CLI Script Sample - Restrict web traffic | Microsoft Docs
3
+
description: Azure CLI Script Sample - Create an application gateway with a web application firewall and a virtual machine scale set that uses OWASP rules to restrict traffic.
4
+
services: application-gateway
5
+
documentationcenter: networking
6
+
author: davidmu1
7
+
manager: timlt
8
+
editor: tysonn
9
+
tags: azure-resource-manager
10
+
11
+
ms.service: application-gateway
12
+
ms.topic: sample
13
+
ms.tgt_pltfrm: vm-windows
14
+
ms.workload: infrastructure
15
+
ms.date: 01/29/2018
16
+
ms.author: davidmu
17
+
ms.custom: mvc
18
+
---
19
+
20
+
# Restrict web traffic using the Azure CLI
21
+
22
+
This script creates an application gateway with a web application firewall that uses a virtual machine scale set for backend servers. The web application firewall restricts web traffic based on OWASP rules. After running the script, you can test the application gateway using its public IP address.
Run the following command to remove the resource group, application gateway, and all related resources.
35
+
36
+
```azurecli-interactive
37
+
az group delete --name myResourceGroupAG --yes
38
+
```
39
+
40
+
## Script explanation
41
+
42
+
This script uses the following commands to create the deployment. Each item in the table links to command specific documentation.
43
+
44
+
| Command | Notes |
45
+
|---|---|
46
+
|[az group create](https://docs.microsoft.com/cli/azure/group#az_group_create)| Creates a resource group in which all resources are stored. |
47
+
|[az network vnet create](https://docs.microsoft.com/cli/azure/network/vnet#az_net)| Creates a virtual network. |
48
+
|[az network vnet subnet create](https://docs.microsoft.com/cli/azure/network/vnet/subnet#az_network_vnet_subnet_create)| Creates a subnet in a virtual network. |
49
+
|[az network public-ip create](https://docs.microsoft.com/cli/azure/public-ip#az_network_public_ip_create)| Creates the public IP address for the application gateway. |
50
+
|[az network application-gateway create](https://docs.microsoft.com/cli/azure/application-gateway#az_application_gateway_create)| Create an application gateway. |
51
+
|[az vmss create](https://docs.microsoft.com/cli/azure/vmss#az_vmss_create)| Creates a virtual machine scale set. |
52
+
|[az storage account create](https://docs.microsoft.com/cli/azure/storage/account#az_storage_account_create)| Creates a storage account. |
53
+
|[az monitor diagnostic-settings create](https://docs.microsoft.com/cli/azure/monitor/diagnostic-settings#az_monitor_diagnostic_settings_create)| Creates a storage account. |
54
+
|[az network public-ip show](https://docs.microsoft.com/cli/azure/network/public-ip#az_network_public_ip_show)| Gets the public IP address of the application gateway. |
55
+
56
+
## Next steps
57
+
58
+
For more information on the Azure CLI, see [Azure CLI documentation](https://docs.microsoft.com/cli/azure/overview).
59
+
60
+
Additional application gateway CLI script samples can be found in the [Azure application gateway documentation](../cli-samples.md).
title: Azure PowerShell Script Sample - Restrict web traffic | Microsoft Docs
3
+
description: Azure PowerShell Script Sample - Create an application gateway with a web application firewall and a virtual machine scale set that uses OWASP rules to restrict traffic.
4
+
services: application-gateway
5
+
documentationcenter: networking
6
+
author: davidmu1
7
+
manager: timlt
8
+
editor: tysonn
9
+
tags: azure-resource-manager
10
+
11
+
ms.service: application-gateway
12
+
ms.topic: sample
13
+
ms.tgt_pltfrm: vm-windows
14
+
ms.workload: infrastructure
15
+
ms.date: 01/29/2018
16
+
ms.author: davidmu
17
+
ms.custom: mvc
18
+
---
19
+
20
+
# Restrict web traffic using Azure PowerShell
21
+
22
+
This script creates an application gateway with a web application firewall that uses a virtual machine scale set for backend servers. The web application firewall restricts web traffic based on OWASP rules. After running the script, you can test the application gateway using its public IP address.
This script uses the following commands to create the deployment. Each item in the table links to command specific documentation.
43
+
44
+
| Command | Notes |
45
+
|---|---|
46
+
|[New-AzureRmResourceGroup](/powershell/module/azurerm.resources/new-azurermresourcegroup)| Creates a resource group in which all resources are stored. |
47
+
|[New-AzureRmVirtualNetworkSubnetConfig](/powershell/module/azurerm.network/new-azurermvirtualnetworksubnetconfig)| Creates the subnet configuration. |
48
+
|[New-AzureRmVirtualNetwork](/powershell/module/azurerm.network/new-azurermvirtualnetwork)| Creates the virtual network using with the subnet configurations. |
49
+
|[New-AzureRmPublicIpAddress](/powershell/module/azurerm.network/new-azurermpublicipaddress)| Creates the public IP address for the application gateway. |
50
+
|[New-AzureRmApplicationGatewayIPConfiguration](/powershell/module/azurerm.network/new-azurermapplicationgatewayipconfiguration)| Creates the configuration that associates a subnet with the application gateway. |
51
+
|[New-AzureRmApplicationGatewayFrontendIPConfig](/powershell/module/azurerm.network/new-azurermapplicationgatewayfrontendipconfig)| Creates the configuration that assigns a public IP address to the application gateway. |
52
+
|[New-AzureRmApplicationGatewayFrontendPort](/powershell/module/azurerm.network/new-azurermapplicationgatewayfrontendport)| Assigns a port to be used to access the application gateway. |
53
+
|[New-AzureRmApplicationGatewayBackendAddressPool](/powershell/module/azurerm.network/new-azurermapplicationgatewaybackendaddresspool)| Creates a backend pool for an application gateway. |
54
+
|[New-AzureRmApplicationGatewayBackendHttpSettings](/powershell/module/azurerm.network/new-azurermapplicationgatewaybackendhttpsettings)| Configures settings for a backend pool. |
55
+
|[New-AzureRmApplicationGatewayHttpListener](/powershell/module/azurerm.network/new-azurermapplicationgatewayhttplistener)| Creates a listener. |
56
+
|[New-AzureRmApplicationGatewayRequestRoutingRule](/powershell/module/azurerm.network/new-azurermapplicationgatewayrequestroutingrule)| Creates a routing rule. |
57
+
|[New-AzureRmApplicationGatewaySku](/powershell/module/azurerm.network/new-azurermapplicationgatewaysku)| Specify the tier and capacity for an application gateway. |
58
+
|[New-AzureRmApplicationGatewayWebApplicationFirewallConfiguration](/powershell/module/azurerm.network/new-azurermapplicationgatewaywebapplicationfirewallconfiguration)| Creates the web application firewall configuration. |
59
+
|[New-AzureRmApplicationGateway](/powershell/module/azurerm.network/new-azurermapplicationgateway)| Create an application gateway. |
60
+
|[Set-AzureRmVmssStorageProfile](/powershell/module/azurerm.compute/set-azurermvmssstorageprofile)| Create a storage profile for the scale set. |
61
+
|[Set-AzureRmVmssOsProfile](/powershell/module/azurerm.compute/set-azurermvmssosprofile)| Define the operating system for the scale set. |
62
+
|[Add-AzureRmVmssNetworkInterfaceConfiguration](/powershell/module/azurerm.compute/add-azurermvmssnetworkinterfaceconfiguration)| Define the network interface for the scale set. |
63
+
|[New-AzureRmVmss](/powershell/module/azurerm.compute/new-azurermvm)| Create a virtual machine scale set. |
64
+
|[New-AzureRmStorageAccount](/powershell/module/azurerm.storage/new-azurermstorageaccount)| Creates a storage account. |
65
+
|[Set-AzureRmDiagnosticSetting](/powershell/module/azurerm.insights/set-azurermdiagnosticsetting)| Configures diagnostics to record data. |
66
+
|[Get-AzureRmPublicIPAddress](/powershell/module/azurerm.network/get-azurermpublicipaddress)| Gets the public IP address of an application gateway. |
67
+
|[Remove-AzureRmResourceGroup](/powershell/module/azurerm.resources/remove-azurermresourcegroup)| Removes a resource group and all resources contained within. |
68
+
## Next steps
69
+
70
+
For more information on the Azure PowerShell module, see [Azure PowerShell documentation](/powershell/azure/overview).
71
+
72
+
Additional application gateway PowerShell script samples can be found in the [Azure Application Gateway documentation](../powershell-samples.md).
Copy file name to clipboardExpand all lines: articles/application-gateway/tutorial-url-redirect-cli.md
+32-14Lines changed: 32 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,24 @@
1
1
---
2
-
title: Create an application gateway with URL path-based redirection - Azure CLI | Microsoft Docs
2
+
title: Create an application gateway with URL path-based redirection - Azure CLI
3
3
description: Learn how to create an application gateway with URL path-based redirected traffic using the Azure CLI.
4
4
services: application-gateway
5
-
author: davidmu1
6
-
manager: timlt
7
-
editor: tysonn
5
+
author: vhorne
6
+
manager: jpconnock
8
7
9
8
ms.service: application-gateway
10
-
ms.topic: article
9
+
ms.topic: tutorial
11
10
ms.workload: infrastructure-services
12
-
ms.date: 01/24/2018
13
-
ms.author: davidmu
11
+
ms.date: 3/28/2018
12
+
ms.author: victorh
13
+
ms.custom: mvc
14
+
#Customer intent: As an IT administrator, I want to use Azure CLI to set up URL path redirection of web traffic to specific pools of servers so I can ensure my customers have access to the information they need.
14
15
15
16
---
16
-
# Create an application gateway with URL path-based redirection using the Azure CLI
17
+
# Tutorial: Create an application gateway with URL path-based redirection using the Azure CLI
17
18
18
19
You can use the Azure CLI to configure [URL path-based routing rules](application-gateway-url-route-overview.md) when you create an [application gateway](application-gateway-introduction.md). In this tutorial, you create backend pools using [virtual machine scale sets](../virtual-machine-scale-sets/virtual-machine-scale-sets-overview.md). You then create URL routing rules that make sure web traffic is redirected to the appropriate backend pool.
19
20
20
-
In this article, you learn how to:
21
+
In this tutorial, you learn how to:
21
22
22
23
> [!div class="checklist"]
23
24
> * Set up the network
@@ -57,19 +58,21 @@ az network vnet create \
57
58
--address-prefix 10.0.0.0/16 \
58
59
--subnet-name myAGSubnet \
59
60
--subnet-prefix 10.0.1.0/24
61
+
60
62
az network vnet subnet create \
61
63
--name myBackendSubnet \
62
64
--resource-group myResourceGroupAG \
63
65
--vnet-name myVNet \
64
66
--address-prefix 10.0.2.0/24
67
+
65
68
az network public-ip create \
66
69
--resource-group myResourceGroupAG \
67
70
--name myAGPublicIPAddress
68
71
```
69
72
70
73
## Create an application gateway
71
74
72
-
You can use [az network application-gateway create](/cli/azure/application-gateway#create) to create the application gateway named myAppGateway. When you create an application gateway using the Azure CLI, you specify configuration information, such as capacity, sku, and HTTP settings. The application gateway is assigned to *myAGSubnet* and *myPublicIPSddress* that you previously created.
75
+
Use [az network application-gateway create](/cli/azure/application-gateway#create) to create the application gateway named myAppGateway. When you create an application gateway using the Azure CLI, you specify configuration information, such as capacity, sku, and HTTP settings. The application gateway is assigned to *myAGSubnet* and *myPublicIPSddress* that you previously created.
73
76
74
77
```azurecli-interactive
75
78
az network application-gateway create \
@@ -87,7 +90,7 @@ az network application-gateway create \
87
90
--public-ip-address myAGPublicIPAddress
88
91
```
89
92
90
-
It may take several minutes for the application gateway to be created. After the application gateway is created, you can see these new features of it:
93
+
It may take several minutes for the application gateway to be created. After the application gateway is created, you can see these new features:
91
94
92
95
-*appGatewayBackendPool* - An application gateway must have at least one backend address pool.
93
96
-*appGatewayBackendHttpSettings* - Specifies that port 80 and an HTTP protocol is used for communication.
@@ -105,15 +108,18 @@ az network application-gateway address-pool create \
105
108
--gateway-name myAppGateway \
106
109
--resource-group myResourceGroupAG \
107
110
--name imagesBackendPool
111
+
108
112
az network application-gateway address-pool create \
109
113
--gateway-name myAppGateway \
110
114
--resource-group myResourceGroupAG \
111
115
--name videoBackendPool
116
+
112
117
az network application-gateway frontend-port create \
113
118
--port 8080 \
114
119
--gateway-name myAppGateway \
115
120
--resource-group myResourceGroupAG \
116
121
--name bport
122
+
117
123
az network application-gateway frontend-port create \
118
124
--port 8081 \
119
125
--gateway-name myAppGateway \
@@ -135,6 +141,7 @@ az network application-gateway http-listener create \
135
141
--frontend-port bport \
136
142
--resource-group myResourceGroupAG \
137
143
--gateway-name myAppGateway
144
+
138
145
az network application-gateway http-listener create \
139
146
--name redirectedListener \
140
147
--frontend-ip appGatewayFrontendIP \
@@ -158,6 +165,7 @@ az network application-gateway url-path-map create \
To get the public IP address of the application gateway, you can use [az network public-ip show](/cli/azure/network/public-ip#az_network_public_ip_show). Copy the public IP address, and then paste it into the address bar of your browser. Such as, *http://40.121.222.19*, *http://40.121.222.19:8080/images/test.htm*, *http://40.121.222.19:8080/video/test.htm*, or *http://40.121.222.19:8081/images/test.htm*.
281
+
To get the public IP address of the application gateway, use [az network public-ip show](/cli/azure/network/public-ip#az_network_public_ip_show). Copy the public IP address, and then paste it into the address bar of your browser. Such as, *http://40.121.222.19*, *http://40.121.222.19:8080/images/test.htm*, *http://40.121.222.19:8080/video/test.htm*, or *http://40.121.222.19:8081/images/test.htm*.
271
282
272
283
```azurepowershell-interactive
273
284
az network public-ip show \
@@ -279,16 +290,23 @@ az network public-ip show \
279
290
280
291

281
292
282
-
Change the URL to http://<ip-address>:8080/video/test.html, substituting your IP address for <ip-address>, and you should see something like the following example:
293
+
Change the URL to http://<ip-address>:8080/images/test.html, substituting your IP address for <ip-address>, and you should see something like the following example:
283
294
284
295

285
296
286
-
Change the URL to http://<ip-address>:8080/video/test.html, substituting your IP address for <ip-address>, and you should see something like the following example.
297
+
Change the URL to http://<ip-address>:8080/video/test.html, substituting your IP address for <ip-address>, and you should see something like the following example:
287
298
288
299

289
300
290
301
Now, change the URL to http://<ip-address>:8081/images/test.htm, substituting your IP address for <ip-address>, and you should see traffic redirected back to the images backend pool at http://<ip-address>:8080/images.
291
302
303
+
## Clean up resources
304
+
305
+
When no longer needed, remove the resource group, application gateway, and all related resources.
306
+
307
+
```azurecli-interactive
308
+
az group delete --name myResourceGroupAG --location eastus
0 commit comments