Get Started with Azure DNS using PowerShell

This article walks you through the steps to create your first DNS zone and record using Azure PowerShell. You can also perform these steps using the Azure portal or the cross-platform Azure CLI.

A DNS zone is used to host the DNS records for a particular domain. To start hosting your domain in Azure DNS, you need to create a DNS zone for that domain name. Each DNS record for your domain is then created inside this DNS zone. Finally, to publish your DNS zone to the Internet, you need to configure the name servers for the domain. Each of these steps is described below.

These instructions assume you have already installed and signed in to Azure PowerShell. For help, see How to manage DNS zones using PowerShell.

Create a DNS zone

A DNS zone is created by using the New-AzureRmDnsZone cmdlet. The following example creates a DNS zone called contoso.com in the resource group called MyResourceGroup. Use the example to create a DNS zone, substituting the values for your own.

New-AzureRmDnsZone -Name contoso.com -ResourceGroupName MyResourceGroup

Create a DNS record

You create record sets by using the New-AzureRmDnsRecordSet cmdlet. The following example creates a record with the relative name "www" in the DNS Zone "contoso.com", in resource group "MyResourceGroup". The fully-qualified name of the record set is "www.contoso.com". The record type is "A", with IP address "1.2.3.4", and the TTL is 3600 seconds.

New-AzureRmDnsRecordSet -Name www -RecordType A -ZoneName contoso.com -ResourceGroupName MyResourceGroup -Ttl 3600 -DnsRecords (New-AzureRmDnsRecordConfig -IPv4Address "1.2.3.4")

For other record types, for record sets with more than one record, and to modify existing records, see Manage DNS records and record sets using Azure PowerShell.

View records

To list the DNS records in your zone, use:

Get-AzureRmDnsRecordSet -ZoneName contoso.com -ResourceGroupName MyResourceGroup

Update name servers

Once you are satisfied that your DNS zone and records have been set up correctly, you need to configure your domain name to use the Azure DNS name servers. This enables other users on the Internet to find your DNS records.

The name servers for your zone are given by the Get-AzureRmDnsZone cmdlet:

Get-AzureRmDnsZone -ZoneName contoso.com -ResourceGroupName MyResourceGroup

Name                  : contoso.com
ResourceGroupName     : myresourcegroup
Etag                  : 00000003-0000-0000-b40d-0996b97ed101
Tags                  : {}
NameServers           : {ns1-01.azure-dns.com., ns2-01.azure-dns.net., ns3-01.azure-dns.org., ns4-01.azure-dns.info.}
NumberOfRecordSets    : 3
MaxNumberOfRecordSets : 5000

These name servers should be configured with the domain name registrar (where you purchased the domain name). Your registrar will offer the option to set up the name servers for the domain. For more information, see Delegate your domain to Azure DNS.

Next steps

To learn more about Azure DNS, see Azure DNS overview.

To learn more about managing DNS zones in Azure DNS, see Manage DNS zones in Azure DNS using PowerShell.

To learn more about managing DNS records in Azure DNS, see Manage DNS records and record sets in Azure DNS using PowerShell.