Introduction

In this quick post we see how to export and import DNS Zones and it’s Record Set to the Azure DNS Service by using two simple commands, one for export and another for import.

Prerequisites

For this quick demo we make sure that we have:

Export DNS Zone With All Records

To export a DNS Zone with all records we follow the next steps,

1. Open the Powershell as Administrator

Click the Search button and type "Powershell"

2. Execute the export-dnsserverzone command

In the Powershell IDE execute the following script

C:\>export-dnsserverzone -name "mydomain.gr -name" -filename "exportDNS.gr"

3. Save the file to .txt extension

The file is located in C:\Windows\System32\dns, copy the file to a new folder, e.g

C:\DNS_Export\exportDNS and save it as a .txt file C:\DNS_Export\exportDNS.txt

Import DNS Zone With All Records

To import the Zone and the records that we previously export we must do the following.

  Important
Azure DNS supports importing and exporting zone files by using the Azure command-line interface (CLI). Zone file import is not currently supported via Azure PowerShell or the Azure portal.

 

1. Open the Windows CMD as Administrator

Click the Search button and type "cmd"

2. Execute Commands For The Import

The following CLI commands, Login, Set the default Azure Subscription and do the DNS records import to the Azure DNS service.

c:\>az login
c:\>az account set --subscription xxxxxxxx-yyyy-aaaa-rrrr-nnnnnnnnnnnn
C:\>az network dns zone import -g ResourceGroup -n mydomain.gr -f "C:\dns\mydomainexport.txt"

And the results will show as follows:

C:\>az network dns zone import -g ResourceGroup-n mydomain.gr -f "C:\dns\mydomainexport.txt"
== BEGINNING ZONE IMPORT: mydomain.gr==
 
(1/6) Imported 1 records of type 'soa' and name '@'
(3/6) Imported 2 records of type 'NS' and name '@'
(4/6) Imported 1 records of type 'a' and name '@'
(5/6) Imported 1 records of type 'a' and name 'g'
(6/6) Imported 1 records of type 'a' and name 'www'
 
== 6/6 RECORDS IMPORTED SUCCESSFULLY: 'mydomain.gr' ==



Summary

In this post we read how easy is to move an on-premise DNS Server to Azure DNS service in a few steps.

See Also