Skip to content

Commit 131d5fb

Browse files
authored
Merge pull request #109225 from vhorne/waf-qs-arm
start arm qs deployment
2 parents de9b9a5 + 1255ba2 commit 131d5fb

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: 'Quickstart: Create an Azure WAF v2 on Application Gateway - Resource Manager template'
3+
titleSuffix: Azure Application Gateway
4+
description: Learn how to use a Resource Manager template to create a Web Application Firewall v2 on Azure Application Gateway.
5+
services: web-application-firewall
6+
author: vhorne
7+
ms.service: web-application-firewall
8+
ms.topic: quickstart
9+
ms.date: 04/02/2020
10+
ms.author: victorh
11+
---
12+
13+
# Quickstart: Create an Azure WAF v2 on Application Gateway - Resource Manager template
14+
15+
In this quickstart, you use a Resource Manager template to create an Azure Web Application Firewall v2 on Application Gateway.
16+
17+
[!INCLUDE [About Azure Resource Manager](../../../includes/resource-manager-quickstart-introduction.md)]
18+
19+
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
20+
21+
## Prerequisites
22+
23+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
24+
25+
## Create a Web Application Firewall
26+
27+
This template creates a simple Web Application Firewall v2 on Azure Application Gateway. This includes a public IP frontend IP address, HTTP settings, a rule with a basic listener on port 80, and a backend pool. A WAF policy with a custom rule is created to block traffic to the backend pool based on an IP address match type.
28+
29+
### Review the template
30+
31+
The template used in this quickstart is from [Azure Quickstart templates](https://github.com/Azure/azure-quickstart-templates/blob/master/ag-docs-wafv2/azuredeploy.json)
32+
33+
:::code language="json" source="~/quickstart-templates/ag-docs-wafv2/azuredeploy.json" range="001-404" highlight="314-358":::
34+
35+
Multiple Azure resources are defined in the template:
36+
37+
- [**Microsoft.Network/applicationgateways**](/azure/templates/microsoft.network/applicationgateways)
38+
- [**Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies**](/azure/templates/microsoft.network/ApplicationGatewayWebApplicationFirewallPolicies)
39+
- [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses) : one for the application gateway, and two for the virtual machines.
40+
- [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups)
41+
- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks)
42+
- [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines) : two virtual machines
43+
- [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces) : two for the virtual machines
44+
- [**Microsoft.Compute/virtualMachine/extensions**](/azure/templates/microsoft.compute/virtualmachines/extensions) : to configure IIS and the web pages
45+
46+
### Deploy the template
47+
48+
Deploy Resource Manager template to Azure:
49+
50+
1. Select **Deploy to Azure** to sign in to Azure and open the template. The template creates an application gateway, the network infrastructure, and two virtual machines in the backend pool running IIS.
51+
52+
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fag-docs-wafv2%2Fazuredeploy.json"><img src="../media/quick-create-template/deploy-to-azure.png" alt="deploy to azure"/></a>
53+
54+
2. Select or create your resource group.
55+
3. Select **I agree to the terms and conditions stated above** and then select **Purchase**. The deployment can take 10 minutes or longer to complete.
56+
57+
## Validate the deployment
58+
59+
Although IIS isn't required to create the application gateway, it's installed on the backend servers to verify if Azure successfully created a WAF v2 on the application gateway.
60+
61+
Use IIS to test the application gateway:
62+
63+
1. Find the public IP address for the application gateway on its **Overview** page.![Record application gateway public IP address](../../application-gateway/media/application-gateway-create-gateway-portal/application-gateway-record-ag-address.png) Or, you can select **All resources**, enter *myAGPublicIPAddress* in the search box, and then select it in the search results. Azure displays the public IP address on the **Overview** page.
64+
2. Copy the public IP address, and then paste it into the address bar of your browser to browse that IP address.
65+
3. Check the response. A **403 Forbidden** response verifies that the WAF was successfully created and is blocking connections to the backend pool.
66+
4. Change the custom rule to **Allow traffic**.
67+
Run the following Azure PowerShell script, replacing your resource group name:
68+
```azurepowershell
69+
$rg = <your resource group name>
70+
$AppGW = Get-AzApplicationGateway -Name myAppGateway -ResourceGroupName $rg
71+
$pol = Get-AzApplicationGatewayFirewallPolicy -Name WafPol01 -ResourceGroupName $rg
72+
$pol[0].customrules[0].action = "allow"
73+
$rule = $pol.CustomRules
74+
Set-AzApplicationGatewayFirewallPolicy -Name WafPol01 -ResourceGroupName $rg -CustomRule $rule
75+
$AppGW.FirewallPolicy = $pol
76+
Set-AzApplicationGateway -ApplicationGateway $AppGW
77+
```
78+
79+
Refresh your browser multiple times and you should see connections to both myVM1 and myVM2.
80+
81+
## Clean up resources
82+
83+
When you no longer need the resources that you created with the application gateway, delete the resource group. This removes the application gateway and all the related resources.
84+
85+
To delete the resource group, call the `Remove-AzResourceGroup` cmdlet:
86+
87+
```azurepowershell-interactive
88+
Remove-AzResourceGroup -Name <your resource group name>
89+
```
90+
91+
## Next steps
92+
93+
> [!div class="nextstepaction"]
94+
> [Tutorial: Create an application gateway with a Web Application Firewall using the Azure portal](application-gateway-web-application-firewall-portal.md)
3.08 KB
Loading

articles/web-application-firewall/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
items:
1919
- name: Web Application Firewall on Azure CDN
2020
href: ./cdn/cdn-overview.md
21+
- name: Quickstarts
22+
expanded: true
23+
items:
24+
- name: Application Gateway
25+
items:
26+
- name: Deploy WAF v2 - ARM template
27+
displayName: Resource Manager
28+
href: ./ag/quick-create-template.md
2129
- name: Tutorials
2230
items:
2331
- name: Application Gateway

0 commit comments

Comments
 (0)