Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f96d0da

Browse files
committedApr 20, 2018
mvc-10
1 parent d17cdcd commit f96d0da

File tree

8 files changed

+220
-14
lines changed

8 files changed

+220
-14
lines changed
 
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Azure Application Gateway Azure CLI Samples | Microsoft Docs
3+
description: Application Gateway Azure CLI Samples
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: article
13+
ms.tgt_pltfrm: vm-windows
14+
ms.workload: infrastructure
15+
ms.date: 01/30/2018
16+
ms.author: davidmu
17+
ms.custom: mvc
18+
19+
---
20+
# Azure Application Gateway Azure CLI samples
21+
22+
The following table includes links to Azure CLI script samples that create application gateways.
23+
24+
| | |
25+
|---|---|
26+
| [Manage web traffic](./scripts/create-vmss-cli.md) | Creates an application gateway and all related resources. |
27+
| [Restrict web traffic](./scripts/create-vmss-waf-cli.md) | Creates an application gateway that restricts traffic using OWASP rules.|
28+
| | |
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Azure Application Gateway PowerShell Samples | Microsoft Docs
3+
description: Azure Application Gateway PowerShell Samples
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: article
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+
# Azure Application Gateway PowerShell samples
20+
21+
The following table includes links to Azure PowerShell script samples that create application gateways.
22+
23+
| | |
24+
|---|---|
25+
| [Manage web traffic](./scripts/create-vmss-powershell.md) | Creates an application gateway and all related resources.|
26+
| [Restrict web traffic](./scripts/create-vmss-waf-powershell.md) | Creates an application gateway that restricts traffic using OWASP rules.|
27+
| | |
28+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
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.
23+
24+
[!INCLUDE [sample-cli-install](../../../includes/sample-cli-install.md)]
25+
26+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
27+
28+
## Sample script
29+
30+
[!code-azurecli-interactive[main](../../../cli_scripts/application-gateway/create-vmss/create-vmss-waf.sh "Create application gateway")]
31+
32+
## Clean up deployment
33+
34+
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).
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
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.
23+
24+
[!INCLUDE [sample-powershell-install](../../../includes/sample-powershell-install-no-ssh.md)]
25+
26+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
27+
28+
## Sample script
29+
30+
[!code-powershell[main](../../../powershell_scripts/application-gateway/create-vmss/create-vmss-waf.ps1 "Create application gateway with WAF")]
31+
32+
## Clean up deployment
33+
34+
Run the following command to remove the resource group, application gateway, and all related resources.
35+
36+
```powershell
37+
Remove-AzureRmResourceGroup -Name myResourceGroupAG
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+
| [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).

‎articles/application-gateway/tutorial-url-redirect-cli.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
---
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
33
description: Learn how to create an application gateway with URL path-based redirected traffic using the Azure CLI.
44
services: application-gateway
5-
author: davidmu1
6-
manager: timlt
7-
editor: tysonn
5+
author: vhorne
6+
manager: jpconnock
87

98
ms.service: application-gateway
10-
ms.topic: article
9+
ms.topic: tutorial
1110
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.
1415

1516
---
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
1718

1819
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.
1920

20-
In this article, you learn how to:
21+
In this tutorial, you learn how to:
2122

2223
> [!div class="checklist"]
2324
> * Set up the network
@@ -57,19 +58,21 @@ az network vnet create \
5758
--address-prefix 10.0.0.0/16 \
5859
--subnet-name myAGSubnet \
5960
--subnet-prefix 10.0.1.0/24
61+
6062
az network vnet subnet create \
6163
--name myBackendSubnet \
6264
--resource-group myResourceGroupAG \
6365
--vnet-name myVNet \
6466
--address-prefix 10.0.2.0/24
67+
6568
az network public-ip create \
6669
--resource-group myResourceGroupAG \
6770
--name myAGPublicIPAddress
6871
```
6972

7073
## Create an application gateway
7174

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.
7376

7477
```azurecli-interactive
7578
az network application-gateway create \
@@ -87,7 +90,7 @@ az network application-gateway create \
8790
--public-ip-address myAGPublicIPAddress
8891
```
8992

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:
9194

9295
- *appGatewayBackendPool* - An application gateway must have at least one backend address pool.
9396
- *appGatewayBackendHttpSettings* - Specifies that port 80 and an HTTP protocol is used for communication.
@@ -105,15 +108,18 @@ az network application-gateway address-pool create \
105108
--gateway-name myAppGateway \
106109
--resource-group myResourceGroupAG \
107110
--name imagesBackendPool
111+
108112
az network application-gateway address-pool create \
109113
--gateway-name myAppGateway \
110114
--resource-group myResourceGroupAG \
111115
--name videoBackendPool
116+
112117
az network application-gateway frontend-port create \
113118
--port 8080 \
114119
--gateway-name myAppGateway \
115120
--resource-group myResourceGroupAG \
116121
--name bport
122+
117123
az network application-gateway frontend-port create \
118124
--port 8081 \
119125
--gateway-name myAppGateway \
@@ -135,6 +141,7 @@ az network application-gateway http-listener create \
135141
--frontend-port bport \
136142
--resource-group myResourceGroupAG \
137143
--gateway-name myAppGateway
144+
138145
az network application-gateway http-listener create \
139146
--name redirectedListener \
140147
--frontend-ip appGatewayFrontendIP \
@@ -158,6 +165,7 @@ az network application-gateway url-path-map create \
158165
--default-http-settings appGatewayBackendHttpSettings \
159166
--http-settings appGatewayBackendHttpSettings \
160167
--rule-name imagePathRule
168+
161169
az network application-gateway url-path-map rule create \
162170
--gateway-name myAppGateway \
163171
--name videoPathRule \
@@ -207,6 +215,7 @@ az network application-gateway rule create \
207215
--rule-type PathBasedRouting \
208216
--url-path-map urlpathmap \
209217
--address-pool appGatewayBackendPool
218+
210219
az network application-gateway rule create \
211220
--gateway-name myAppGateway \
212221
--name redirectedRule \
@@ -235,6 +244,7 @@ for i in `seq 1 3`; do
235244
then
236245
poolName="videoBackendPool"
237246
fi
247+
238248
az vmss create \
239249
--name myvmss$i \
240250
--resource-group myResourceGroupAG \
@@ -262,12 +272,13 @@ for i in `seq 1 3`; do
262272
--resource-group myResourceGroupAG \
263273
--vmss-name myvmss$i \
264274
--settings '{ "fileUris": ["https://raw.githubusercontent.com/davidmu1/samplescripts/master/install_nginx.sh"], "commandToExecute": "./install_nginx.sh" }'
275+
265276
done
266277
```
267278

268279
## Test the application gateway
269280

270-
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*.
271282

272283
```azurepowershell-interactive
273284
az network public-ip show \
@@ -279,16 +290,23 @@ az network public-ip show \
279290

280291
![Test base URL in application gateway](./media/tutorial-url-redirect-cli/application-gateway-nginx.png)
281292

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:
283294

284295
![Test images URL in application gateway](./media/tutorial-url-redirect-cli/application-gateway-nginx-images.png)
285296

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:
287298

288299
![Test video URL in application gateway](./media/tutorial-url-redirect-cli/application-gateway-nginx-video.png)
289300

290301
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.
291302

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
309+
```
292310
## Next steps
293311

294312
In this tutorial, you learned how to:

0 commit comments

Comments
 (0)
Please sign in to comment.