DNS
🌐 What is Azure DNS?¶
Azure DNS is a Domain Name System (DNS) hosting service that lets you host your DNS domains and manage DNS records using Azure infrastructure.
It translates human-readable domain names (like
myapp.com) into IP addresses (like52.161.10.5) to route traffic properly.
📚 Table of Contents¶
-
What is DNS? (Quick Recap)
-
What is Azure DNS?
-
Key Features
-
Azure DNS Types
-
Supported DNS Record Types
-
Hands-On Setup (Portal & CLI)
-
Custom Domain Mapping (Azure Web Apps)
-
Azure Private DNS
-
Best Practices
-
Interview Questions
1️⃣ What is DNS? (Quick Recap)¶
-
DNS = Phonebook of the internet
-
Maps domain names to IP addresses
-
Works with recursive and authoritative name servers
2️⃣ What is Azure DNS?¶
Azure DNS allows you to:
-
Host public or private DNS zones
-
Manage DNS records with Azure CLI, PowerShell, REST
-
Use role-based access control (RBAC) and activity logs
✅ Low latency
✅ Global reach
✅ Secure & reliable
3️⃣ Key Features¶
| Feature | Description |
|---|---|
| Public & Private DNS Zones | Support for internal and external name resolution |
| Record Management | A, AAAA, CNAME, MX, TXT, etc. |
| Azure Integration | VMs, App Services, Traffic Manager |
| Role-based Access | Control DNS using Azure RBAC |
| Fast Resolution | Powered by Azure’s global network of name servers |
| Monitoring | Activity logs, alerts, diagnostics |
4️⃣ Azure DNS Types¶
| Type | Description | Use Case |
|---|---|---|
| Public DNS Zone | DNS zone accessible from internet | Host public website or API |
| Private DNS Zone | Internal-only DNS within a VNet | Resolve internal VM names securely |
5️⃣ Supported DNS Record Types¶
| Record Type | Description | Example |
|---|---|---|
| A | Maps name to IPv4 | app.contoso.com → 192.168.1.1 |
| AAAA | Maps name to IPv6 | app.contoso.com → 2607:f8b0::1 |
| CNAME | Alias to another domain | www.contoso.com → contoso.com |
| MX | Mail server | For email routing |
| TXT | Text data | SPF, DKIM |
| NS | Name server | Delegation of zones |
| PTR | Reverse DNS | IP to domain name |
| SRV | Service location | Skype, LDAP |
6️⃣ Hands-On: Create a Public DNS Zone¶
✅ Azure Portal¶
-
Go to DNS Zones → Create
-
Enter:
-
Name:
example.com -
Resource group
-
-
Create records (e.g., A, CNAME)
💻 Azure CLI¶
# Create a DNS zone
az network dns zone create \
--name example.com \
--resource-group myRG
# Create an A record
az network dns record-set a add-record \
--zone-name example.com \
--resource-group myRG \
--record-set-name www \
--ipv4-address 52.160.10.10
# Create a CNAME record
az network dns record-set cname set-record \
--zone-name example.com \
--resource-group myRG \
--record-set-name blog \
--cname contoso.azurewebsites.net
7️⃣ Custom Domain Mapping (e.g., for App Service)¶
If you're using Azure Web App (app.azurewebsites.net) and want to map www.myapp.com:
-
Add a CNAME record in Azure DNS:
-
Go to App Service → Custom domains → Add
www.myapp.com -
Validate DNS & bind it.
8️⃣ Azure Private DNS Zones¶
| Feature | Description |
|---|---|
| Internal-only name resolution | |
| Uses VNet link to associate | |
| Automatically resolves Azure VM names | |
| No need for custom DNS servers |
Example:¶
-
Create private zone:
internal.contoso.com -
Link it to your VNet
-
Add A record:
web1 → 10.1.1.4 -
VMs in the VNet can now use
web1.internal.contoso.com
9️⃣ Best Practices¶
| Practice | Why |
|---|---|
| Use Azure DNS for global reliability | Fast resolution using Azure’s DNS infrastructure |
| Use CNAME for web apps | Easier to change endpoints |
| Use Private DNS for internal services | Secure name resolution inside VNets |
| Use RBAC | Control who can edit DNS records |
| Enable DNS zone logging | Audit and monitor changes |