Symptom
You built a VM in a VNet that is supposed to register into a private DNS zone such as corp.internal. One of these happens:
nslookup app01.corp.internalreturns NXDOMAIN, and the zone has noapp01record.- The record is there, but VMs in another VNet or on-premises can't resolve it.
- The record vanished overnight and came back when someone started the VM.
- A second VNet's VMs never register, even though "autoregistration is on".
Autoregistration is a property of a virtual network link, not of the zone or the VM. Nearly every failure comes down to which link exists, whether it has registration turned on, and where the VM sends its DNS queries.
How autoregistration behaves
These rules come from the Azure Private DNS documentation. They explain most tickets:
| Rule | What it means in practice |
|---|---|
Registration is set per VNet link (registrationEnabled) | A resolution-only link never creates records |
| A VNet can have registration enabled on only one private zone link | A second zone can't also collect the same VNet's VMs |
| Only virtual machines are registered | Internal load balancers, private endpoints and other resources need manual records |
| Records are removed when a VM is deleted or stopped (deallocated) | A deallocated VM can't be resolved, and its record comes back when the VM starts |
| PTR records aren't autoregistered | Reverse lookups only return the zone name through Azure's resolver |
| If DHCP is disabled in the guest (static IP inside the OS), changes to the host name or IP aren't picked up | The zone keeps the stale name or address |
Checks, in order
1. Does the VM's VNet have a registration link to the zone?
RG=rg-dns
ZONE=corp.internal
az network private-dns link vnet list -g $RG -z $ZONE \
--query "[].{link:name, vnet:virtualNetwork.id, registration:registrationEnabled, state:virtualNetworkLinkState, prov:provisioningState}" \
-o table
You want the VM's VNet listed with registration set to True, state set to Completed and prov set to Succeeded. If the VNet is missing, nothing registers. If it shows False, it is a resolution-only link.
Turn registration on for an existing link:
az network private-dns link vnet update -g $RG -z $ZONE -n link-spoke1 --registration-enabled true
Or create the link:
VNET_ID=$(az network vnet show -g rg-spoke1 -n vnet-spoke1 --query id -o tsv)
az network private-dns link vnet create -g $RG -z $ZONE -n link-spoke1 \
--virtual-network $VNET_ID --registration-enabled true
2. Is the VNet already registering into a different zone?
If link vnet create or update fails with a conflict, the VNet already has a registration link somewhere else, often a zone made by another team or left over from a lab. Resource Graph finds it across every subscription you can read:
az graph query -q "
resources
| where type =~ 'microsoft.network/privatednszones/virtualnetworklinks'
| extend vnet = tolower(tostring(properties.virtualNetwork.id)),
registration = tobool(properties.registrationEnabled),
zone = tostring(split(id, '/')[8])
| where registration == true
| project zone, linkName = name, vnet, resourceGroup, subscriptionId
| order by vnet asc" --first 1000 -o table
If you find the VNet registering into the wrong zone, decide which zone owns that VNet. Turn registration off on the old link, then turn it on for the right one.
Warning
When you disable registration on a link, Azure removes the records it registered through that link. Anything that still resolves the old names will start getting NXDOMAIN. Find those clients first, or create manual records in the old zone for the names you still need.
3. Is the VM running, and is the record really missing?
az vm get-instance-view -g rg-spoke1 -n app01 \
--query "instanceView.statuses[?starts_with(code,'PowerState')].displayStatus" -o tsv
az network private-dns record-set a list -g $RG -z $ZONE \
--query "[].{name:name, ip:aRecords[0].ipv4Address, auto:isAutoRegistered, ttl:ttl}" -o table
VM deallocatedexplains a missing record. It is expected behaviour. If something has to resolve the name while the VM is off, such as a DR runbook or monitoring, use a manual record in a zone that has no registration link.autoset toTruemeans Azure created the record.Falsemeans a person or a pipeline created it, so Azure won't update or remove it when the VM's IP changes.- If the record shows an old IP, check whether the guest uses a static IP in the OS instead of DHCP. Switch the guest back to DHCP and keep a static address on the NIC in Azure instead:
az network nic ip-config update -g rg-spoke1 --nic-name app01-nic -n ipconfig1 \
--private-ip-address 10.20.1.10
4. Where does the VM send DNS queries?
Registration happens on the platform side, but resolution only works if queries reach Azure's resolver, 168.63.129.16. Check the VNet's DNS servers:
az network vnet show -g rg-spoke1 -n vnet-spoke1 --query "dhcpOptions.dnsServers" -o tsv
An empty result means Azure-provided DNS, which resolves linked private zones. If you see custom DNS servers (domain controllers, a third-party appliance or an on-premises IP), those servers must forward corp.internal (or everything) to 168.63.129.16. They also have to run inside a VNet that is linked to the zone, because 168.63.129.16 only answers for zones linked to the VNet the query comes from.
Test from inside the VM with Run Command, no login needed:
az vm run-command invoke -g rg-spoke1 -n app01 --command-id RunShellScript \
--scripts "nslookup app01.corp.internal 168.63.129.16; nslookup app01.corp.internal"
For Windows, use --command-id RunPowerShellScript and Resolve-DnsName app01.corp.internal -Server 168.63.129.16; Resolve-DnsName app01.corp.internal.
| Result | Cause | Fix |
|---|---|---|
| Both lookups fail | No record, or this VNet isn't linked | Go back to checks 1–3 |
| Lookup against 168.63.129.16 works, default lookup fails | Custom DNS server doesn't forward the zone | Add a conditional forwarder to 168.63.129.16 from a linked VNet, or use DNS Private Resolver |
| Works in the registering VNet, fails in a peered spoke | Spoke has no link to the zone | Add a resolution-only link (--registration-enabled false) |
| On-premises clients fail | No inbound path into Azure DNS | Use a DNS Private Resolver inbound endpoint or forwarder VMs in a linked VNet |
5. Did someone change the link?
az monitor activity-log list -g $RG --offset 7d \
--query "[?contains(operationName.value, 'virtualNetworkLinks')].{time:eventTimestamp, op:operationName.value, who:caller, status:status.value}" \
-o table
If you find a recent delete or write on a link, you know who to talk to, and the fix is to recreate the link from check 1.
Records autoregistration won't create
Create these yourself, and keep them in code next to the resource:
az network private-dns record-set a add-record -g $RG -z $ZONE -n sql-listener -a 10.20.2.50
az network private-dns record-set cname set-record -g $RG -z $ZONE -n api -c ilb-api.corp.internal
Common candidates are internal load balancer frontends, SQL Server availability group listeners, appliances and the extra IP configurations a VM uses for specific services.
Tip
Avoid manual records that use the same name as a VM. Two sources managing one name makes it unclear which IP will be returned after the next restart.
Prevent it next time
- Give each VNet exactly one registration zone, recorded in its IaC module. Add resolution-only links everywhere else.
- Run the Resource Graph query from check 2 on a schedule. Alert on VNets with no registration link, and on links that aren't
Completed. - Keep guest OS networking on DHCP. Set static addresses on the Azure NIC instead.
- For any name that must resolve while a VM is deallocated, use a manual record or a load balancer, not autoregistration.
- Put a
CanNotDeletelock on the private DNS zones. Deleting a zone removes every link and record at once. - Document the forwarding chain (custom DNS, then 168.63.129.16 or Private Resolver) so whoever changes VNet DNS settings knows what depends on it.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get