Skip to content

Commit edd2612

Browse files
authored
Merge pull request #201310 from Harikrishnan-M-B/QSG
AFD Premium Quick Start Guide - CLI
2 parents 494160c + f2bbcff commit edd2612

File tree

3 files changed

+77
-74
lines changed

3 files changed

+77
-74
lines changed
79.9 KB
Loading
71.6 KB
Loading

articles/frontdoor/standard-premium/create-front-door-cli.md

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Create an Azure Front Door Standard/Premium with the Azure CLI
3-
description: Learn how to create an Azure Front Door Standard/Premium (preview) with the Azure CLI. Use the Front Door to protect your web apps against vulnerabilities.
2+
title: Create an Azure Front Door Premium with the Azure CLI
3+
description: Learn how to create an Azure Front Door Premium with Azure CLI. Use Azure Front Door to deliver content to your global user base and protect your web apps against vulnerabilities.
44
ms.topic: sample
55
author: duau
66
ms.author: duau
@@ -10,43 +10,35 @@ ms.custom: devx-track-azurecli
1010

1111
---
1212

13-
# Quickstart: Create an Azure Front Door Standard/Premium - Azure CLI
13+
# Quickstart: Create an Azure Front Door Premium - Azure CLI
1414

15-
In this quickstart, you'll learn how to create an Azure Front Door Standard/Premium profile using the Azure CLI. You'll create this profile using two Web Apps as your origin, and add a WAF security policy. You can then verify connectivity to your Web Apps using the Azure Front Door Standard/Premium frontend hostname.
15+
In this quickstart, you'll learn how to create an Azure Front Door Premium profile using Azure CLI. You'll create this profile using two Web Apps as your origin, and add a WAF security policy. You can then verify connectivity to your Web Apps using the Azure Front Door endpoint hostname.
1616

1717
> [!NOTE]
18-
> This documentation is for Azure Front Door Standard/Premium (Preview). Looking for information on Azure Front Door? View [Azure Front Door Docs](../front-door-overview.md).
18+
> This documentation is for Azure Front Door Standard/Premium. Looking for information on Azure Front Door? View [Azure Front Door Docs](../front-door-overview.md).
1919
2020
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2121

2222
[!INCLUDE [azure-cli-prepare-your-environment](../../../includes/azure-cli-prepare-your-environment.md)]
2323

2424
## Create a resource group
2525

26-
For this quickstart, you'll need two resource groups. One in *Central US* and the second in *East US*.
26+
In Azure, you allocate related resources to a resource group. You can either use an existing resource group or create a new one.
2727

28-
Run [az group create](/cli/azure/group#az-group-create) to create resource groups.
28+
Run [az group create](/cli/azure/group) to create resource groups.
2929

3030
```azurecli
31-
az group create \
32-
--name myRGFDCentral \
33-
--location centralus
34-
35-
az group create \
36-
--name myRGFDEast \
37-
--location eastus
31+
az group create --name myRGFD --location centralus
3832
```
39-
4033
## Create an Azure Front Door profile
4134

4235
Run [az afd profile create](/cli/azure/afd/profile#az-afd-profile-create) to create an Azure Front Door profile.
4336

4437
```azurecli
4538
az afd profile create \
4639
--profile-name contosoafd \
47-
--resource-group myRGFDCentral \
48-
--sku Premium_AzureFrontDoor \
49-
--subscription mysubscription
40+
--resource-group myRGFD \
41+
--sku Premium_AzureFrontDoor
5042
```
5143

5244
## Create two instances of a web app
@@ -64,31 +56,27 @@ Run [az appservice plan create](/cli/azure/appservice/plan#az-appservice-plan-cr
6456
```azurecli
6557
az appservice plan create \
6658
--name myAppServicePlanCentralUS \
67-
--resource-group myRGFDCentral
59+
--resource-group myRGFD
6860
6961
az appservice plan create \
7062
--name myAppServicePlanEastUS \
71-
--resource-group myRGFDEast
63+
--resource-group myRGFD
7264
```
7365

7466
### Create web apps
7567

7668
Run [az webapp create](/cli/azure/webapp#az-webapp-create&preserve-view=true) to create a web app in each of the app service plans in the previous step. Web app names have to be globally unique.
7769

78-
Run [az webapp list-runtimes](/cli/azure/webapp#az-webapp-create&preserve-view=true) to see a list of built-in stacks for web apps.
79-
8070
```azurecli
8171
az webapp create \
82-
--name WebAppContoso-001 \
83-
--resource-group myRGFDCentral \
84-
--plan myAppServicePlanCentralUS \
85-
--runtime "DOTNETCORE|2.1"
72+
--name WebAppContoso-01 \
73+
--resource-group myRGFD \
74+
--plan myAppServicePlanCentralUS
8675
8776
az webapp create \
88-
--name WebAppContoso-002 \
89-
--resource-group myRGFDEast \
90-
--plan myAppServicePlanEastUS \
91-
--runtime "DOTNETCORE|2.1"
77+
--name WebAppContoso-02 \
78+
--resource-group myRGFD \
79+
--plan myAppServicePlanEastUS
9280
```
9381

9482
Make note of the default host name of each web app so you can define the backend addresses when you deploy the Front Door in the next step.
@@ -99,10 +87,9 @@ Run [az afd endpoint create](/cli/azure/afd/endpoint#az-afd-endpoint-create) to
9987

10088
```azurecli
10189
az afd endpoint create \
102-
--resource-group myRGFDCentral \
103-
--endpoint-name contoso-frontend \
90+
--resource-group myRGFD \
91+
--endpoint-name contosofrontend \
10492
--profile-name contosoafd \
105-
--origin-response-timeout-seconds 60 \
10693
--enabled-state Enabled
10794
```
10895

@@ -112,13 +99,13 @@ Run [az afd origin-group create](/cli/azure/afd/origin-group#az-afd-origin-group
11299

113100
```azurecli
114101
az afd origin-group create \
115-
--resource-group myRGFDCentral \
116-
--origin-group-name og1 \
102+
--resource-group myRGFD \
103+
--origin-group-name og2 \
117104
--profile-name contosoafd \
118105
--probe-request-type GET \
119106
--probe-protocol Http \
120-
--probe-interval-in-seconds 120 \
121-
--probe-path /test1/azure.txt \
107+
--probe-interval-in-seconds 60 \
108+
--probe-path / \
122109
--sample-size 4 \
123110
--successful-samples-required 3 \
124111
--additional-latency-in-milliseconds 50
@@ -130,12 +117,12 @@ Run [az afd origin create](/cli/azure/afd/origin#az-afd-origin-create) to add an
130117

131118
```azurecli
132119
az afd origin create \
133-
--resource-group myRGFDCentral \
134-
--host-name webappcontoso-1.azurewebsites.net
120+
--resource-group myRGFD \
121+
--host-name webappcontoso-01.azurewebsites.net \
135122
--profile-name contosoafd \
136-
--origin-group-name og1 \
123+
--origin-group-name og \
137124
--origin-name contoso1 \
138-
--origin-host-header webappcontoso-1.azurewebsites.net \
125+
--origin-host-header webappcontoso-01.azurewebsites.net \
139126
--priority 1 \
140127
--weight 1000 \
141128
--enabled-state Enabled \
@@ -147,12 +134,12 @@ Repeat this step and add your second origin.
147134

148135
```azurecli
149136
az afd origin create \
150-
--resource-group myRGFDCentral \
151-
--host-name webappcontoso-2.azurewebsites.net
137+
--resource-group myRGFD \
138+
--host-name webappcontoso-02.azurewebsites.net \
152139
--profile-name contosoafd \
153-
--origin-group-name og1 \
140+
--origin-group-name og \
154141
--origin-name contoso2 \
155-
--origin-host-header webappcontoso-2.azurewebsites.net \
142+
--origin-host-header webappcontoso-02.azurewebsites.net \
156143
--priority 1 \
157144
--weight 1000 \
158145
--enabled-state Enabled \
@@ -162,35 +149,33 @@ az afd origin create \
162149

163150
## Add a route
164151

165-
Run [az afd route create](/cli/azure/afd/route#az-afd-route-create) to map your frontend endpoint to the origin group. This route forwards requests from the endpoint to *og1*.
152+
Run [az afd route create](/cli/azure/afd/route#az-afd-route-create) to map your endpoint to the origin group. This route forwards requests from the endpoint to your origin group.
166153

167154
```azurecli
168155
az afd route create \
169-
--resource-group myRGFDCentral \
170-
--endpoint-name contoso-frontend \
156+
--resource-group myRGFD \
171157
--profile-name contosoafd \
172-
--route-name route1 \
158+
--endpoint-name contosofrontend \
159+
--forwarding-protocol MatchRequest \
160+
--route-name route \
173161
--https-redirect Enabled \
174-
--origin-group og1 \
175-
--supported-protocols Https \
176-
--link-to-default-domain Enabled \
177-
--forwarding-protocol MatchRequest
162+
--origin-group og \
163+
--supported-protocols Http Https \
164+
--link-to-default-domain Enabled
178165
```
179166

180167
## Create a new security policy
181168

182169
### Create a WAF policy
183170

184-
Run [az network front-door waf-policy create](/cli/azure/network/front-door/waf-policy#az-network-front-door-waf-policy-create) to create a WAF policy for one of your resource groups.
185-
186-
Create a new WAF policy for your Front Door. This example creates a policy that's enabled and in prevention mode.
171+
Run [az network front-door waf-policy create](/cli/azure/network/front-door/waf-policy#az-network-front-door-waf-policy-create) to create a new WAF policy for your Front Door. This example creates a policy that is enabled and in prevention mode.
187172

188173
```azurecli
189-
az network front-door waf-policy create
190-
--name contosoWAF /
191-
--resource-group myRGFDCentral /
192-
--sku Premium_AzureFrontDoor
193-
--disabled false /
174+
az network front-door waf-policy create \
175+
--name contosoWAF \
176+
--resource-group myRGFD \
177+
--sku Premium_AzureFrontDoor \
178+
--disabled false \
194179
--mode Prevention
195180
```
196181

@@ -201,26 +186,40 @@ az network front-door waf-policy create
201186

202187
Run [az afd security-policy create](/cli/azure/afd/security-policy#az-afd-security-policy-create) to apply your WAF policy to the endpoint's default domain.
203188

189+
> [!NOTE]
190+
> Substitute 'mysubscription' with your Azure Subscription ID in the domains and waf-policy parameters below. Run [az account subscription list](/cli/azure/aaccount/subscription#az-account-subscription-list) to get Subscription ID details.
191+
192+
204193
```azurecli
205194
az afd security-policy create \
206-
--resource-group myRGFDCentral \
195+
--resource-group myRGFD \
207196
--profile-name contosoafd \
208197
--security-policy-name contososecurity \
209-
--domains /subscriptions/mysubscription/resourcegroups/myRGFDCentral/providers/Microsoft.Cdn/profiles/contosoafd/afdEndpoints/contoso-frontend.z01.azurefd.net \
210-
--waf-policy /subscriptions/mysubscription/resourcegroups/myRGFDCentral/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/contosoWAF
198+
--domains /subscriptions/mysubscription/resourcegroups/myRGFD/providers/Microsoft.Cdn/profiles/contosoafd/afdEndpoints/contosofrontend \
199+
--waf-policy /subscriptions/mysubscription/resourcegroups/myRGFD/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/contosoWAF
211200
```
212201

213202
## Verify Azure Front Door
214203

215-
When you create the Azure Front Door Standard/Premium profile, it takes a few minutes for the configuration to be deployed globally. Once completed, you can access the frontend host you created. In a browser, go to `contoso-frontend.z01.azurefd.net`. Your request will automatically get routed to the nearest server from the specified servers in the origin group.
204+
When you create the Azure Front Door Standard/Premium profile, it takes a few minutes for the configuration to be deployed globally. Once completed, you can access the frontend host you created.
216205

217-
To test instant global failover, we'll use the following steps:
206+
Run [az afd endpoint show](/cli/azure/afd/endpoint#az-afd-endpoint-show) to get the hostname of the Front Door endpoint.
218207

219-
1. Open a browser, as described above, and go to the frontend address: `contoso-frontend.azurefd.net`.
208+
```azurecli
209+
az afd endpoint show --resource-group myRGFD --profile-name contosoafd --endpoint-name contosofrontend
210+
```
211+
In a browser, go to the endpoint hostname: `contosofrontend-<hash>.z01.azurefd.net`. Your request will automatically get routed to the least latent Web App in the origin group.
220212

221-
2. In the Azure portal, search for and select *App services*. Scroll down to find one of your web apps, **WebAppContoso-1** in this example.
222213

223-
3. Select your web app, and then select **Stop**, and **Yes** to verify.
214+
215+
To test instant global failover, we'll use the following steps:
216+
217+
1. Open a browser, as described above, and go to the endpoint hostname: `contosofrontend-<hash>.z01.azurefd.net`.
218+
219+
2. Stop one of the Web Apps by running [az webapp stop](/cli/azure/webapp#az-webapp-stop&preserve-view=true)
220+
```azurecli
221+
az webapp stop --name WebAppContoso-01 --resource-group myRGFD
222+
```
224223

225224
4. Refresh your browser. You should see the same information page.
226225

@@ -229,10 +228,17 @@ To test instant global failover, we'll use the following steps:
229228
230229
5. Find the other web app, and stop it as well.
231230

231+
```azurecli
232+
az webapp stop --name WebAppContoso-02 --resource-group myRGFD
233+
```
234+
232235
6. Refresh your browser. This time, you should see an error message.
233236

234-
:::image type="content" source="../media/create-front-door-portal/web-app-stopped-message.png" alt-text="Both instances of the web app stopped":::
237+
7. Restart one of the Web Apps by running [az webapp start](/cli/azure/webapp#az-webapp-start&preserve-view=true). Refresh your browser and the page will go back to normal.
235238

239+
```azurecli
240+
az webapp start --name WebAppContoso-01 --resource-group myRGFD
241+
```
236242
## Clean up resources
237243

238244
When you don't need the resources for the Front Door, delete both resource groups. Deleting the resource groups also deletes the Front Door and all its related resources.
@@ -241,10 +247,7 @@ Run [az group delete](/cli/azure/group#az-group-delete&preserve-view=true):
241247

242248
```azurecli
243249
az group delete \
244-
--name myRGFDCentral
245-
246-
az group delete \
247-
--name myRGFDEast
250+
--name myRGFD
248251
```
249252

250253
## Next steps

0 commit comments

Comments
 (0)