1. Answers
  2. Configure Azure Private DNS Zone Virtual Network Link

How do I configure an Azure Private DNS Zone Virtual Network Link?

In this guide, we will configure an Azure Private DNS Zone and link it to a Virtual Network using Pulumi. This setup allows you to manage DNS records within a private zone and link them to a specific virtual network, providing name resolution for VMs within that network.

Key Points:

  • Create a Resource Group.
  • Create a Virtual Network.
  • Create a Private DNS Zone.
  • Link the Private DNS Zone to the Virtual Network.
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";

// Create an Azure Resource Group
const resourceGroup = new azure.resources.ResourceGroup("resourceGroup", {
    resourceGroupName: "exampleResourceGroup",
    location: "WestEurope",
});

// Create a Virtual Network
const virtualNetwork = new azure.network.VirtualNetwork("virtualNetwork", {
    resourceGroupName: resourceGroup.name,
    location: resourceGroup.location,
    addressSpace: {
        addressPrefixes: ["10.0.0.0/16"],
    },
});

// Create a Subnet
const subnet = new azure.network.Subnet("subnet", {
    resourceGroupName: resourceGroup.name,
    virtualNetworkName: virtualNetwork.name,
    addressPrefix: "10.0.1.0/24",
});

// Create a Private DNS Zone
const privateDnsZone = new azure.network.PrivateZone("privateDnsZone", {
    resourceGroupName: resourceGroup.name,
    location: "global",
    privateZoneName: "example.private.zone",
});

// Link the Private DNS Zone to the Virtual Network
const virtualNetworkLink = new azure.network.VirtualNetworkLink("virtualNetworkLink", {
    resourceGroupName: resourceGroup.name,
    privateZoneName: privateDnsZone.name,
    location: "global",
    virtualNetwork: {
        id: virtualNetwork.id,
    },
    registrationEnabled: true,
});

Summary:

In this guide, we created a Resource Group, a Virtual Network, and a Private DNS Zone. We then linked the Private DNS Zone to the Virtual Network, enabling DNS resolution within the network. This setup is essential for managing DNS records privately within Azure.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up