Azure DNS Zones and Records
This tutorial guides you through managing DNS zones and records within Azure DNS. Azure DNS provides a highly available and globally routed DNS service for resolving names in your own custom domains. By hosting your domains in Azure, you can manage your DNS records using the same credentials, APIs, and billing as your other Azure services.
What are DNS Zones and Records?
A DNS zone represents a domain, such as contoso.com. The DNS zone file contains the records that translate names within that domain to IP addresses.
DNS records are entries within a DNS zone that provide specific information about domain names. Common record types include:
- A records: Map a hostname to an IPv4 address.
- AAAA records: Map a hostname to an IPv6 address.
- CNAME records: Create aliases for other hostnames.
- MX records: Specify mail servers responsible for accepting email messages for the domain.
- TXT records: Store text information, often used for verification purposes (e.g., SPF records).
- SRV records: Specify the location of servers for specific services.
Creating a DNS Zone in Azure
To get started, you need to create a DNS zone for your domain in Azure.
- Sign in to the Azure portal.
- In the search bar at the top, type "DNS zones" and select it from the results.
- Click Create.
- Select your subscription and resource group. If you don't have one, you can create a new one.
- Enter your domain name in the Name field (e.g.,
contoso.com). - Choose the resource group and location.
- Click Review + create, and then click Create.
Once created, Azure provides you with the Name Servers (NS records) for your domain. You'll need to update your domain registrar's settings to point to these Name Servers.
Adding DNS Records
After creating your DNS zone, you can start adding records. Let's add an A record to point www.contoso.com to an Azure VM's public IP address.
- Navigate to your newly created DNS zone in the Azure portal.
- Click + Record set.
- In the Name field, enter
www. - Select A for the Type.
- Enter the public IP address of your Azure resource in the IP address field.
- Leave the TTL and TTL unit as default or adjust as needed.
- Click OK.
You can repeat this process for other record types like CNAME, MX, and TXT.
Example: Adding a CNAME Record
To alias blog.contoso.com to another hostname, for instance, an Azure App Service, you would add a CNAME record.
Name: blog
Type: CNAME
Alias: your-app-service.azurewebsites.net
TTL: 1 Hour
Managing DNS Records with Azure CLI
You can also manage DNS zones and records using the Azure Command-Line Interface (CLI).
First, log in to your Azure account:
az login
Create a DNS zone:
az network dns zone create \
--resource-group myResourceGroup \
--name contoso.com
Add an A record:
az network dns record-set a add-record \
--resource-group myResourceGroup \
--zone-name contoso.com \
--record-set-name www \
--ipv4-address 203.0.113.5
Add a CNAME record:
az network dns record-set cname set-record \
--resource-group myResourceGroup \
--zone-name contoso.com \
--record-set-name blog \
--cname your-app-service.azurewebsites.net
myResourceGroup and domain names with your actual resource group and domain names.
Next Steps
This tutorial covered the basics of creating DNS zones and managing records. You can further explore advanced features such as:
- Creating Alias Records to reference Azure resources directly.
- Using Traffic Manager for global traffic routing.
- Implementing DNS Security Extensions (DNSSEC).
- Setting up Private DNS Zones for internal network resolution.
For more detailed information, refer to the official Azure DNS documentation.