Featured image of post Importing an Azure DNS Zone

Importing an Azure DNS Zone

Do you need to strat from scratch with Azure DNS or can you import your existing zones?

What happens if you want to get started with Azure DNS but have a mature DNS environment based on Active Directory integrated DNS, BIND or even a third part Domain Registrar? The good news is you don’t need to start from scratch or manually start creating records you can just import your DNS zone file into Azure DNS. Note: At the time of writing (January 2022) you MUST use CLI – there is no option to use the portal directly or even PowerShell.

It is possible to import most record types - A, AAAA, CAA, CNAME, MX, NS, SOA, SRV, and TXT but it’s worth bearing in mind only single-string TXT records are supported. Multistring records will be concatenated.

How do I get my zone file to import?

If you’re using a Domain Registrar, you should find an option in your management portal that allows you to download the DNS zone file. BIND uses a configuration file called named.conf that will specify the name and location of the zone file for each zone it’s hosting. An Active Directory DNS uses the default folder is %systemroot%\system32\dns. You can find the zone file with a .dns file type. One thing to note here is if you’re using Active Directory integrated DNS your DNS zone will be store within AD and not within the file. You will need to export the zone using the dnscmd: dnscmd NLAZRADS01 /ZoneExport pzcussonstest.com export.txt

Importing your zone file

The code you need (again, this is only supported in CLI at this time) is:

az network private-dns zone import -g {YOUR RESOURCE GROUP NAME} -n {YOUR ZONE NAME} -f {YOUR ZONE FILE}

When importing the zone file it’s worth noting that an imported CNAME record does not replace an existing CNAME record that shares the same name. This means any records in Azure DNS wouldn’t be updated.

Exporting your zone file

Reversely you can export a zone from Azure DNS should you need. This can be achieved with the command:

az network private-dns zone export -g {YOUR RESOURCE GROUP NAME} -n {YOUR ZONE NAME} -f {YOUR ZONE FILE}

Things to note:

  • If your record does not include a TTL the default TTL for the zone will be used.
  • If a TTL does exist, the pre-existing will be used.
  • The SOA is always taken from the imported zone file except for Hosts.
  • ALL existing new (from the zone file) and existing (any records already present in the Azure DNS zone) are merged. If there are any duplications, they are de-duplicated.
Built with Hugo
Theme Stack designed by Jimmy