Azure Network Frontdoor

This page shows how to write Terraform and Azure Resource Manager for Network Frontdoor and write them securely.

azurerm_frontdoor (Terraform)

The Frontdoor in Network can be configured in Terraform with the resource name azurerm_frontdoor. The following sections describe 8 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L34
resource "azurerm_frontdoor" "frontdoorkata" {
    name                                         = "frontdoorkata111"
    resource_group_name                          = data.azurerm_resource_group.kata1ResourceGroup.name
    enforce_backend_pools_certificate_name_check = true

    routing_rule {
main.tf#L1
resource "azurerm_frontdoor" "front_door" {
  name                                         = var.front_door_name
  resource_group_name                          = var.resource_group_name
  enforce_backend_pools_certificate_name_check = var.enforce_cert_check
  tags                                         = var.tags

front-door.tf#L1
resource "azurerm_frontdoor" "example" {
  name                                         = var.front_door_name
  resource_group_name                          = data.azurerm_resource_group.resource-group.name
  enforce_backend_pools_certificate_name_check = false

  routing_rule {
main.tf#L17
resource "azurerm_frontdoor" "example" {
  name                                         = "example-FrontDoor-CentralAPP"
  location                                     = "Global"
  resource_group_name                          = azurerm_resource_group.example.name
  enforce_backend_pools_certificate_name_check = false

frontdoor.tf#L10
resource "azurerm_frontdoor" "frontdoor" {
  name                                         = "fd-appgw-sample"
  location                                     = var.location
  resource_group_name                          = azurerm_resource_group.rg.name
  enforce_backend_pools_certificate_name_check = false

positive.tf#L1
resource "azurerm_frontdoor" "positive" {
  name                                         = "example-FrontDoor"
  resource_group_name                          = azurerm_resource_group.example.name
  enforce_backend_pools_certificate_name_check = false

  routing_rule {
negative.tf#L1
resource "azurerm_frontdoor" "negative" {
  name                                         = "example-FrontDoor"
  resource_group_name                          = azurerm_resource_group.example.name
  enforce_backend_pools_certificate_name_check = false

  routing_rule {
main.tf#L1
resource "azurerm_frontdoor" "azfd" {
  name                                         = local.azfd_name
  resource_group_name                          = local.rsgr_name
  enforce_backend_pools_certificate_name_check = false

  routing_rule {

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an Azure Front Door instance. Azure Front Door Service is Microsoft's highly available and scalable web application acceleration platform and global HTTP(s) load balancer. It provides built-in DDoS protection and application layer security and caching. Front Door enables you to build applications that maximize and automate high-availability and performance for your end-users. Use Front Door with Azure services including Web/Mobile Apps, Cloud Services and Virtual Machines – or combine it with on-premises services for hybrid deployments and smooth cloud migration. Below are some of the key scenarios that Azure Front Door Service addresses:

  • Use Front Door to improve application scale and availability with instant multi-region failover
  • Use Front Door to improve application performance with SSL offload and routing requests to the fastest available application backend.
  • Use Front Door for application layer security and DDoS protection for your application. !>Be Aware: Azure is rolling out a breaking change on Friday 9th April which may cause issues with the CDN/FrontDoor resources. More information is available in this Github issue - however unfortunately this may necessitate a breaking change to the CDN and FrontDoor resources, more information will be posted in the Github issue as the necessary changes are identified. !>BREAKING CHANGE: The custom_https_provisioning_enabled field and the custom_https_configuration block have been removed from the azurerm_frontdoor resource in the v2.58.0 provider due to changes made by the service team. If you wish to enable the custom https configuration functionality within your azurerm_frontdoor resource moving forward you will need to define a separate azurerm_frontdoor_custom_https_configuration block in your configuration file. !>BREAKING CHANGE: With the release of the v2.58.0 provider, if you run the apply command against an existing Front Door resource it will not apply the detected changes. Instead it will persist the explicit_resource_order mapping structure to the state file. Once this operation has completed the resource will resume functioning normally.This change in behavior in Terraform is due to an issue where the underlying service teams API is now returning the response JSON out of order from the way it was sent to the resource via Terraform causing unexpected discrepancies in the plan after the resource has been provisioned. If your pre-existing Front Door instance contains custom_https_configuration blocks there are additional steps that will need to be completed to successfully migrate your Front Door onto the v2.58.0 provider which can be found in this guide.

Tips: Best Practices for The Other Azure Network Resources

In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_network_security_group

Ensure to disable RDP port from the Internet

It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.

risk-label

azurerm_network_security_rule

Ensure to set a more restrictive CIDR range for ingress from the internet

It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.

risk-label

azurerm_network_watcher_flow_log

Ensure to enable Retention policy for flow logs and set it to enough duration

It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.

Review your Azure Network settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Network/frontDoors (Azure Resource Manager)

The frontDoors in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/frontDoors. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

frontdoor.json
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "frontdoorName": {
Resources.FrontDoor.json
[
    {
        "ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-test/providers/Microsoft.Network/frontdoors/frontdoor-A",
        "Id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-test/providers/Microsoft.Network/frontdoors/frontdoor-A",
        "Identity": null,
Microsoft.Network.FrontDoor.tests.json#L8
        "type": "Microsoft.Network/frontDoors",
        "name": "[variables('frontDoorName')]",
        "location": "[resourceGroup().location]",
        "properties": {
          "routingRules": [
            {
Microsoft.Network.FrontDoor.tests.json#L8
        "type": "Microsoft.Network/frontDoors",
        "name": "[variables('frontDoorName')]",
        "location": "[resourceGroup().location]",
        "properties": {
          "routingRules": [
            {
Microsoft.Network.FrontDoor.tests.json#L8
        "type": "Microsoft.Network/frontDoors",
        "name": "[variables('frontDoorName')]",
        "location": "[resourceGroup().location]",
        "properties": {
          "routingRules": [
            {
Microsoft.Network.FrontDoor.tests.json#L8
        "type": "Microsoft.Network/frontDoors",
        "name": "[variables('frontDoorName')]",
        "location": "[resourceGroup().location]",
        "properties": {
          "routingRules": [
            {
azuredeploy.json#L30
            "type": "Microsoft.Network/frontDoors",
            "name": "[parameters('frontDoorName')]",
            "location": "[variables('frontdoorLocation')]",
            "properties": {
                "routingRules": [
                    {
main.json#L26
      "type": "Microsoft.Network/frontDoors",
      "apiVersion": "2020-01-01",
      "name": "[parameters('frontDoorName')]",
      "location": "global",
      "properties": {
        "enabledState": "Enabled",
template.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "workflows_trafficcontrol_name": {
azuredeploy.json#L43
      "type": "Microsoft.Network/frontDoors",
      "name": "[variables('frontDoorName')]",
      "location": "[variables('frontdoorLocation')]",
      "tags": {},
      "properties": {
        "routingRules": [

Frequently asked questions

What is Azure Network Frontdoor?

Azure Network Frontdoor is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Network Frontdoor?

For Terraform, the mattykii/azureFrontDoorwithWebapps, andrewCluey/terraform-azurerm-frontdoor and josepht96/learning source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the Theatreers/Theatreers, Azure/PSRule.Rules.Azure and Azure/azure-resource-manager-schemas source code examples are useful. See the Azure Resource Manager Example section for further details.