Quickstart: Create a Front Door using an ARM template

This quickstart describes how to use an Azure Resource Manager template (ARM Template) to create a Front Door to set up high availability for a web endpoint.

An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy to Azure

Prerequisites

  • If you don't have an Azure subscription, create a free account before you begin.
  • IP or FQDN of a website or web application.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

In this quickstart, you'll create a Front Door configuration with a single backend and a single default path matching /*.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "frontDoorName": {
      "type": "string",
      "metadata": {
        "description": "The name of the frontdoor resource."
      }
    },
    "backendAddress": {
      "type": "string",
      "metadata": {
        "description": "The hostname of the backend. Must be an IP address or FQDN."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Network/frontDoors",
      "apiVersion": "2020-07-01",
      "name": "[parameters('frontDoorName')]",
      "location": "global",
      "properties": {
        "routingRules": [
          {
            "name": "routingRule1",
            "properties": {
              "frontendEndpoints": [
                {
                  "id": "[resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontDoorName'), 'frontendEndpoint1')]"
                }
              ],
              "acceptedProtocols": [
                "Http",
                "Https"
              ],
              "patternsToMatch": [
                "/*"
              ],
              "routeConfiguration": {
                "@odata.type": "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration",
                "forwardingProtocol": "MatchRequest",
                "backendPool": {
                  "id": "[resourceId('Microsoft.Network/frontDoors/backendPools', parameters('frontDoorName'), 'backendPool1')]"
                }
              },
              "enabledState": "Enabled"
            }
          }
        ],
        "healthProbeSettings": [
          {
            "name": "healthProbeSettings1",
            "properties": {
              "path": "/",
              "protocol": "Http",
              "intervalInSeconds": 120
            }
          }
        ],
        "loadBalancingSettings": [
          {
            "name": "loadBalancingSettings1",
            "properties": {
              "sampleSize": 4,
              "successfulSamplesRequired": 2
            }
          }
        ],
        "backendPools": [
          {
            "name": "backendPool1",
            "properties": {
              "backends": [
                {
                  "address": "[parameters('backendAddress')]",
                  "backendHostHeader": "[parameters('backendAddress')]",
                  "httpPort": 80,
                  "httpsPort": 443,
                  "weight": 50,
                  "priority": 1,
                  "enabledState": "Enabled"
                }
              ],
              "loadBalancingSettings": {
                "id": "[resourceId('Microsoft.Network/frontDoors/loadBalancingSettings', parameters('frontDoorName'), 'loadBalancingSettings1')]"
              },
              "healthProbeSettings": {
                "id": "[resourceId('Microsoft.Network/frontDoors/healthProbeSettings', parameters('frontDoorName'), 'healthProbeSettings1')]"
              }
            }
          }
        ],
        "frontendEndpoints": [
          {
            "name": "frontendEndpoint1",
            "properties": {
              "hostName": "[concat(parameters('frontDoorName'), '.azurefd.net')]",
              "sessionAffinityEnabledState": "Disabled"
            }
          }
        ],
        "enabledState": "Enabled"
      }
    }
  ]
}

One Azure resource is defined in the template:

Deploy the template

  1. Select Try it from the following code block to open Azure Cloud Shell, and then follow the instructions to sign in to Azure.

    $projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names"
    $location = Read-Host -Prompt "Enter the location (i.e. centralus)"
    $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/front-door-create-basic/azuredeploy.json"
    
    $resourceGroupName = "${projectName}rg"
    
    New-AzResourceGroup -Name $resourceGroupName -Location "$location"
    New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri
    
    Read-Host -Prompt "Press [ENTER] to continue ..."
    

    Wait until you see the prompt from the console.

  2. Select Copy from the previous code block to copy the PowerShell script.

  3. Right-click the shell console pane and then select Paste.

  4. Enter the values.

    The template deployment creates a Front Door with a single backend. In this example microsoft.com is used as the backendAddress.

    The resource group name is the project name with rg appended.

    Note

    frontDoorName needs to be a globally unique name in order for the template to deploy successfully. If deployment fails, start over with Step 1.

    It takes a few minutes to deploy the template. When completed, the output is similar to:

    Front Door Resource Manager template PowerShell deployment output

Azure PowerShell is used to deploy the template. In addition to Azure PowerShell, you can also use the Azure portal, Azure CLI, and REST API. To learn other deployment methods, see Deploy templates.

Validate the deployment

  1. Sign in to the Azure portal.

  2. Select Resource groups from the left pane.

  3. Select the resource group that you created in the previous section. The default resource group name is the project name with rg appended.

  4. Select the Front Door you created previously and click on the Frontend host link. The link will open a web browser redirecting you to your backend FQDN you defined during creation.

    Front Door portal overview

Clean up resources

When you no longer need the Front Door service, delete the resource group. This removes the Front Door and all the related resources.

To delete the resource group, call the Remove-AzResourceGroup cmdlet:

Remove-AzResourceGroup -Name <your resource group name>

Next steps

In this quickstart, you created a Front Door.

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