Managing Azure DNS: The Easy Way™

Managing Azure DNS using the API isn’t terribly easy, and provides no means to easily view all of your DNS records, and manage large sets of them. Small changes require you to work out the commands you need to run, and quickly get out of hand.

For that reason I’ve created this open source tool which makes it much easier to manage all of the DNS records for your domain. It allows you to store your DNS configuration in a text file (possibly keeping it in version control), and makes it much easier to quickly see and understand your domains configuration. The tool also supports importing records from existing DNS servers or importing them if you’ve already added them to Azure. You can then apply these records to Azure using a single command. Easy!

Let’s take a look at how it’s used!

Get the Tool

The tool is available on GitHub. You will need Node JS, and the Azure x-plat CLI installed on your system. The commands to install the Azure CLI, clone the sources, and setup the project are below. You can also skip getting the sources and setting up the project by going to the releases page on the GitHub repository and downloading the latest release (you will still need the Azure CLI).

# Install Azure x-plat CLI (may need to use sudo on linux)
npm install -g azure-cli

# Get the sources
git clone

# Install node dependencies
cd azurednsmanager
npm install

# Test that everything works
node dnsmanager.js -h

Note that you will need to be logged into an Azure ORGID Account in the Azure CLI, and the CLI must be in resource manager mode. To do this run:

azure config mode arm
azure login -u <orgid_email>

Importing your DNS Records

To import DNS records for an existing domain into the text file, use the following command.

node dnsmanager.js -n -i -s DNS --outfile -t 3600

The command explained:

  • -n domain – The domain name to import DNS records from
  • -i – Specifies that the tool run in import mode
  • -s DNS – Sets the import source to an existing DNS server
  • --outfile – Specifies which text file the configuration should be store in.
  • -t 3600 – Sets the TTL for all imported records to 3600 seconds.

After running this command the contents of is:

# Imported DNS records from DNS
@ A 3600   
@ MX 3600 10  
@ MX 3600 10  
@ MX 3600 1  
@ MX 3600 5  
@ MX 3600 5  
@ TXT 3600 MS=ms31401049   
@ TXT 3600 google-site-verification=oawHQrYUfe_-0iaOv9zrIOyEwSEPVACwF9JM3Etmiqw   
@ TXT 3600 "v=spf1 +a +mx +ip4: +ip4: -all"   

As you can see the tool imported all of the records for However, it didn’t import anything from any subdomains. This is because DNS servers don’t allow you to query for a list of subdomains. If you want subdomains included, specify them with the -p option. For example to include records for and you would use the following command:

node dnsmanager.js -n -i -s DNS --outfile -p www,example -t 3600

The text file will now contain all records for those subdomains.

Applying your Records to Azure DNS

Now that you’ve either imported your domains existing records, or created your own records text file it’s time to upload these records to Azure DNS. I assume below that you have already created a resource group named dnsGroup and an Azure DNS Zone for (obviously change this to match your own domain).

node dnsmanager.js -g dnsGroup -n -f -c 50 --dryrun

This will run the importer in dry run mode — meaning that it will display a summary of all the actions it will perform, but not actually make any changes to your Azure DNS configuration.

Here’s what each of the arguments means:

  • -g dnsGroup – Specify that the DNS group for this domain is called dnsGroup
  • -n – Sets the DNS zone to
  • -f – The file to read DNS records from.
  • -c 50 – This is a convenience option and only affects the summary the tool displays. Tells the tool that if any records are over 50 characters long to only show the first 50 characters when it prints out the summary on your terminal. (This is good for very long text records)
  • --dryrun Tells the command to do a dry run and only print the summary of what it will do — don’t actually make any changes to the Azure Configuration.

Once you’ve reviewed the actions the command will apply, remove the --dryrun option and run again:

node dnsmanager.js -g dnsGroup -n -f -c 50

And that’s it! If the command completed without error then all your DNS records have been applied. Try querying the Azure DNS servers!

You can find full documentation on the DNS Manager GitHub Repo. If you have any questions, comments, or you run into problems with the tool, leave me a comment below or submit an issue on the GitHub repo.

, , , , ,

No comments yet.

Leave a Reply

Proudly made in Canada