Skip to content

Files

Latest commit

7e303ca · Mar 18, 2022

History

History
153 lines (103 loc) · 5.87 KB

quickstart-create-front-door-cli.md

File metadata and controls

153 lines (103 loc) · 5.87 KB
title description services author manager ms.service ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author ms.custom ms.devlang
Quickstart: Set up high availability with Azure Front Door - Azure CLI
This quickstart will show you how to use Azure Front Door to create a high availability and high-performance global web application using Azure CLI.
front-door
duongau
KumudD
frontdoor
quickstart
na
infrastructure-services
4/19/2021
duau
mode-api, devx-track-azurecli
azurecli

Quickstart: Create a Front Door for a highly available global web application using Azure CLI

Get started with Azure Front Door by using Azure CLI to create a highly available and high-performance global web application.

The Front Door directs web traffic to specific resources in a backend pool. You defined the frontend domain, add resources to a backend pool, and create a routing rule. This article uses a simple configuration of one backend pool with two web app resources and a single routing rule using default path matching "/*".

:::image type="content" source="media/quickstart-create-front-door/environment-diagram.png" alt-text="Diagram of Front Door deployment environment using the Azure CLI." border="false":::

Prerequisites

  • An Azure account with an active subscription. Create an account for free.
  • Azure CLI installed locally or Azure Cloud Shell
  • Ensure that the front-door extension is added to your Azure CLI
az extension add --name front-door

[!INCLUDE cloud-shell-try-it.md]

If you choose to install and use the CLI locally, this quickstart requires Azure CLI version 2.0.28 or later. To find the version, run az --version. If you need to install or upgrade, see Install the Azure CLI.

Create a resource group

In Azure, you allocate related resources to a resource group. You can either use an existing resource group or create a new one.

For this quickstart, you need two resource groups. One in Central US and the second in South Central US.

Create a resource group with az group create:

az group create \
    --name myRGFDCentral \
    --location centralus

az group create \
    --name myRGFDEast \
    --location eastus

Create two instances of a web app

Two instances of a web application that run in different Azure regions is required for this quickstart. Both the web application instances run in Active/Active mode, so either one can service traffic.

If you don't already have a web app, use the following script to set up two example web apps.

Create app service plans

Before you can create the web apps you will need two app service plans, one in Central US and the second in East US.

Create app service plans with az appservice plan create:

az appservice plan create \
--name myAppServicePlanCentralUS \
--resource-group myRGFDCentral

az appservice plan create \
--name myAppServicePlanEastUS \
--resource-group myRGFDEast

Create web apps

Running the following commands will create a web app in each of the app service plans in the previous step. Web app names have to be globally unique.

Create web app with az webapp create:

az webapp create \
--name WebAppContoso-1 \
--resource-group myRGFDCentral \
--plan myAppServicePlanCentralUS 

az webapp create \
--name WebAppContoso-2 \
--resource-group myRGFDEast \
--plan myAppServicePlanEastUS

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.

Create the Front Door

Create a basic Front Door with default load balancing settings, health probe, and routing rules by running to follow:

Create Front Door with az network front-door create:

az network front-door create \
--resource-group myRGFDCentral \
--name contoso-frontend \
--accepted-protocols Http Https \
--backend-address webappcontoso-1.azurewebsites.net webappcontoso-2.azurewebsites.net 

--resource-group: Specify a resource group where you want to deploy the Front Door.

--name: Specify a globally unique name for your Azure Front Door.

--accepted-protocols: Accepted values are Http and Https. If you want to use both, specific both separated by a space.

--backend-address: Define both web apps host name here separated by a space.

Once the deployment has successfully completed, make note of the host name in the frontEndpoints section.

Test the Front Door

Open a web browser and enter the hostname obtain from the commands. The Front Door will direct your request to one of the backend resources.

:::image type="content" source="./media/quickstart-create-front-door-cli/front-door-testing-page.png" alt-text="Front Door testing page":::

Clean up resources

When you no longer need the resources that you created with the Front Door, delete both resource groups. When you delete the resource group, you also delete the Front Door and all its related resources.

To delete the resource group use az group delete:

az group delete \
--name myRGFDCentral 

az group delete \
--name myRGFDEast

Next steps

In this quickstart, you created a:

  • Front Door
  • Two web apps

To learn how to add a custom domain to your Front Door, continue to the Front Door tutorials.

[!div class="nextstepaction"] Add a custom domain