Get started with Azure DNS using Azure CLI 1.0
This article walks you through the steps to create your first DNS zone and record using the cross-platform Azure CLI 1.0, which is available for Windows, Mac and Linux. You can also perform these steps using the Azure portal or Azure PowerShell.
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 CLI 1.0. For help, see How to manage DNS zones using Azure CLI 1.0.
Create the resource group
Before creating the DNS zone, a resource group is created to contain the DNS Zone. The following shows the command.
azure group create --name MyResourceGroup --location "West US"
Create a DNS zone
A DNS zone is created using the
azure network dns zone create command. To see help for this command, type
azure network dns zone create -h.
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.
azure network dns zone create MyResourceGroup contoso.com
Create a DNS record
To create a DNS record, use the
azure network dns record-set add-record command. For help, see
azure network dns record-set add-record -h.
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 "184.108.40.206", and a default TTL of 3600 seconds (1 hour) is used.
azure network dns record-set add-record MyResourceGroup contoso.com www A -a 220.127.116.11
For other record types, for record sets with more than one record, for alternative TTL values, and to modify existing records, see Manage DNS records and record sets using the Azure CLI 1.0.
To list the DNS records in your zone, use:
azure network dns record-set list MyResourceGroup contoso.com
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
azure network dns zone show command:
azure network dns zone show MyResourceGroup contoso.com info: Executing command network dns zone show + Looking up the dns zone "contoso.com" data: Id : /subscriptions/a385a691-bd93-41b0-8084-8213ebc5bff7/resourceGroups/myresourcegroup/providers/Microsoft.Network/dnszones/contoso.com data: Name : contoso.com data: Type : Microsoft.Network/dnszones data: Location : global data: Number of record sets : 3 data: Max number of record sets : 5000 data: Name servers: data: ns1-01.azure-dns.com. data: ns2-01.azure-dns.net. data: ns3-01.azure-dns.org. data: ns4-01.azure-dns.info. data: Tags : info: network dns zone show command OK
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.
Delete all resources
To delete all resources created in this article, take the following step:
azure group delete --name MyResourceGroup
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 Azure CLI 1.0.
To learn more about managing DNS records in Azure DNS, see Manage DNS records and record sets in Azure DNS using Azure CLI 1.0.