Create Azure DNS zones using CLI

Create the resource group

First, create a resource group to contain the DNS zone:

az group create –name MyAzureResourceGroup –location “East Asia”

Create a DNS zone

az network vnet create \
–name myAzureVNet \
–resource-group MyAzureResourceGroup \
–location eastus \
–address-prefix 10.2.0.0/16 \
–subnet-name backendSubnet \
–subnet-prefix 10.2.0.0/24

az network dns zone create -g MyAzureResourceGroup \
-n chirkut.local \
–zone-type Private \
–registration-vnets myAzureVNet

List DNS zones

az network dns zone list \
–resource-group MyAzureResourceGroup

az network dns zone list

Create an additional DNS record

The following example creates a record with the relative name db in the DNS Zone chirkut.local, in resource group MyAzureResourceGroup. The fully qualified name of the record set is db.chirkut.local. The record type is “A”, with IP address “10.2.0.4”.

az network dns record-set a add-record \
-g MyAzureResourceGroup \
-z chirkut.local \
-n db \
-a 10.2.0.4

View DNS records

To list the DNS records in your zone, run:

az network dns record-set list \
-g MyAzureResourceGroup \
-z chirkut.local

Delete all resources

When no longer needed, delete the MyAzureResourceGroup resource group to delete the resources created in this tutorial.

az group delete –name MyAzureResourceGroup

Leave a Reply

Your email address will not be published. Required fields are marked *