Skip to content

Commit 7d96e21

Browse files
committed
add cli instructions
1 parent aeead0e commit 7d96e21

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

articles/web-application-firewall/afds/waf-front-door-configure-custom-response-code.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ By default, when Azure Web Application Firewall blocks a request because of a ma
3333

3434
You can also [install Azure PowerShell locally](/powershell/azure/install-azure-powershell) to run the cmdlets. This article requires the Azure PowerShell module. If you run PowerShell locally, sign in to Azure using the [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) cmdlet.
3535

36+
# [**Azure CLI**](#tab/cli)
37+
38+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
39+
40+
- Azure Cloud Shell or Azure CLI.
41+
42+
The steps in this article run the Azure CLI commands interactively in [Azure Cloud Shell](/azure/cloud-shell/overview). To run the commands in the Cloud Shell, select **Open Cloud Shell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
43+
44+
You can also [install Azure CLI locally](/cli/azure/install-azure-cli) to run the commands. This article requires the Azure CLI version 2.67.0 or higher and **front-door** extension. Run [az --version](/cli/azure/reference-index#az-version) command to find the installed version. If you run Azure CLI locally, sign in to Azure using the [az login](/cli/azure/reference-index#az-login) command.
45+
3646
---
3747

3848
## Configure a custom response status code and message
@@ -61,7 +71,7 @@ To customize the response status code and body, use [Update-AzFrontDoorWafPolicy
6171

6272

6373
```azurepowershell-interactive
64-
# modify WAF response body
74+
# Update WAF policy settings to customize response body and status code
6575
Update-AzFrontDoorWafPolicy `
6676
-Name 'myWAFPolicy' `
6777
-ResourceGroupName 'myResourceGroup' `
@@ -71,6 +81,25 @@ Update-AzFrontDoorWafPolicy `
7181
-CustomBlockResponseBody '<html><head><title>WAF Demo</title></head><body><p><h1><strong>WAF Custom Response Page</strong></h1></p><p>Please contact us with this information:<br>{{azure-ref}}</p></body></html>'
7282
```
7383

84+
# [**Azure CLI**](#tab/cli)
85+
86+
To customize the response status code and body, use [az network front-door waf-policy update](/cli/azure/network/front-door/waf-policy#az-network-front-door-waf-policy-update) command.
87+
88+
89+
```azurecli-interactive
90+
# Update WAF policy settings to customize response body and status code
91+
az network front-door waf-policy update \
92+
--name 'myWAFPolicy' \
93+
--resource-group 'myResourceGroup' \
94+
--request-body-check 'Enabled' \
95+
--redirect-url 'https://learn.microsoft.com/en-us/azure/web-application-firewall/' \
96+
--custom-block-response-status-code '403' \
97+
--custom-block-response-body 'PGh0bWw+PGhlYWQ+PHRpdGxlPldBRiBEZW1vPC90aXRsZT48L2hlYWQ+PGJvZHk+PHA+PGgxPjxzdHJvbmc+V0FGIEN1c3RvbSBSZXNwb25zZSBQYWdlPC9zdHJvbmc+PC9oMT48L3A+PHA+UGxlYXNlIGNvbnRhY3QgdXMgd2l0aCB0aGlzIGluZm9ybWF0aW9uOjxicj57e2F6dXJlLXJlZn19PC9wPjwvYm9keT48L2h0bWw+'
98+
```
99+
100+
> [!NOTE]
101+
> The value of the `--custom-block-response-body` parameter must be a **base64** encoded string.
102+
74103
---
75104

76105
> [!NOTE]

0 commit comments

Comments
 (0)