Azure Private DNS Zone

This page shows how to write Terraform and Azure Resource Manager for Private DNS Zone and write them securely.

azurerm_private_dns_zone (Terraform)

The Zone in Private DNS can be configured in Terraform with the resource name azurerm_private_dns_zone. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

dns-privatezones.tf#L9
resource "azurerm_private_dns_zone" "azureautomation" {
    provider = azurerm.Connectivity
  name                = "privatelink.azure-automation.net"
  resource_group_name = azurerm_resource_group.dnsprivatezones.name
}

dns-zones.tf#L4
resource "azurerm_private_dns_zone" "acr-dns" {
  name                = "privatelink.azurecr.io"
  resource_group_name = azurerm_resource_group.net-rg.name

}

dns_zones.tf#L9
resource "azurerm_private_dns_zone" "azure_monitor" {
  name                = "privatelink.monitor.azure.com"
  resource_group_name = var.resource_group_name

  lifecycle { ignore_changes = [tags] }
}
private_dns_zone.tf#L2
resource "azurerm_private_dns_zone" "storage" {
  name                = "privatelink.blob.core.windows.net"
  resource_group_name = azurerm_resource_group.terraform.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "storage" {
dnszones.tf#L1
resource "azurerm_private_dns_zone" "database" {
    name                    = "privatelink.database.windows.net"
    resource_group_name     = local.resource_group_name
    tags                    = var.tags
}

vnet-dns.tf#L1
resource "azurerm_private_dns_zone" "private-storage-blob" {
  name                = "privatelink.blob.core.windows.net"
  resource_group_name = azurerm_resource_group.tf-connectivity.name
}

resource "azurerm_private_dns_zone" "private-storage-file" {
dns_zone.tf#L2
resource "azurerm_private_dns_zone" "all-dns-zone" {
  name                = var.dns_names[count.index]
  resource_group_name = azurerm_resource_group.rg.name
  tags                = local.common_tags
  count               = 6
}
dns-zones.tf#L4
resource "azurerm_private_dns_zone" "acr-dns" {
  name                = "privatelink.azurecr.io"
  resource_group_name = azurerm_resource_group.net-rg.name

}

ple_and_dns.tf#L32
resource "azurerm_private_dns_zone" "monitor" {
  name                          = "privatelink.monitor.azure.com"
  resource_group_name           = var.rg.name
}

resource "azurerm_private_dns_zone" "oms" {
dnszone.tf#L2
resource "azurerm_private_dns_zone" "c1" {
  name                = "customer1.com"
  resource_group_name = azurerm_resource_group.C1RG.name
  provider = azurerm.Customer1
}

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

Enables you to manage Private DNS zones within Azure DNS. These zones are hosted on Azure's name servers.

Microsoft.Network/privateDnsZones (Azure Resource Manager)

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

Example Usage from GitHub

DINE-PrivateDNSZonesPolicySetDefinition.json#L22
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    "azureWebPrivateDnsZoneId": {
                        "type": "string",
policy_set_definition_es_deploy_private_dns_zones.tmpl.json#L19
          "strongType": "Microsoft.Network/privateDnsZones",
          "description": "Private DNS Zone Identifier"
        }
      },
      "azureWebPrivateDnsZoneId": {
        "type": "string",
7dns.json#L17
            "type": "Microsoft.Network/privateDnsZones",
            "apiVersion": "2018-09-01",
            "name": "[parameters('privateDnsZones_lablocaliza_lab_name')]",
            "location": "global",
            "properties": {
                "maxNumberOfRecordSets": 25000,
private-dns-template.json#L17
            "type": "Microsoft.Network/privateDnsZones",
            "apiVersion": "2018-09-01",
            "name": "[parameters('privateDnsZones_izzyacademy_com_name')]",
            "location": "global",
            "properties": {
                "maxNumberOfRecordSets": 25000,
private-dns-zones-private-enabled-services.json#L7
    "type": "Microsoft.Network/privateDnsZones",
    "apiVersion": "2020-06-01",
    "name": "privatelink.azure-automation.net",
    "location": "global"
  },
  {
DINE-PrivateDNSZonesPolicySetDefinition.json#L22
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    "azureWebPrivateDnsZoneId": {
                        "type": "string",
fairfaxDINE-PrivateDNSZonesPolicySetDefinition.json#L22
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    "azureBatchPrivateDnsZoneId": {
                        "type": "string",
mcDINE-PrivateDNSZonesPolicySetDefinition.json#L30
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    "azureWebPrivateDnsZoneId": {
                        "type": "string",
DINE-PrivateDNSZonesPolicySetDefinition.json#L22
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    "azureWebPrivateDnsZoneId": {
                        "type": "string",
DINE-PrivateDNSZonesPolicySetDefinition.json#L22
                            "strongType": "Microsoft.Network/privateDnsZones",
                            "description": "Private DNS Zone Identifier"
                        }
                    },
                    // US_Gov_Error_004
                    "azureWebPrivateDnsZoneId": {

Frequently asked questions

What is Azure Private DNS Zone?

Azure Private DNS Zone is a resource for Private DNS of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Private DNS Zone?

For Terraform, the liamfoneill/NotQuiteEnterpriseScale, neelampawar1988/Azure-Arc-Kubenetescluster and microsoft/AzureTRE source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the saq1bahmed/EntScale, tschwarz01/tf-caf-data-management-zone and L4ur0Resend3/Lab source code examples are useful. See the Azure Resource Manager Example section for further details.