Bird
Raised Fist0
Azurecloud~5 mins

Azure DNS basics - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you want to make your website or app reachable by a friendly name instead of numbers, you use DNS. Azure DNS helps you manage these names easily and reliably in the cloud.
When you want to host your domain's DNS records in Azure for better integration with other Azure services.
When you need to create custom domain names for your web apps or services hosted in Azure.
When you want to manage DNS records like A, CNAME, or MX for your domain without running your own DNS servers.
When you want fast and reliable DNS resolution with Azure's global network.
When you want to automate DNS record management using Azure CLI or templates.
Config File - dns-zone.json
dns-zone.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Network/dnsZones",
      "apiVersion": "2018-05-01",
      "name": "exampledomain.com",
      "location": "global",
      "properties": {}
    },
    {
      "type": "Microsoft.Network/dnsZones/A",
      "apiVersion": "2018-05-01",
      "name": "exampledomain.com/www",
      "dependsOn": [
        "Microsoft.Network/dnsZones/exampledomain.com"
      ],
      "properties": {
        "TTL": 3600,
        "ARecords": [
          {
            "ipv4Address": "20.50.40.30"
          }
        ]
      }
    }
  ]
}

This JSON file is an Azure Resource Manager template that creates a DNS zone named exampledomain.com in Azure DNS.

It also creates an A record for www.exampledomain.com pointing to the IP address 20.50.40.30.

The TTL is set to 3600 seconds, which means DNS servers will cache this record for one hour.

This template can be deployed to Azure to set up DNS hosting and records automatically.

Commands
This command creates a DNS zone named exampledomain.com in the resource group myResourceGroup. This is the first step to manage DNS records for your domain in Azure.
Terminal
az network dns zone create --resource-group myResourceGroup --name exampledomain.com
Expected OutputExpected
{ "etag": "00000000-0000-0000-0000-000000000000", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/dnsZones/exampledomain.com", "location": "global", "maxNumberOfRecordSets": 5000, "name": "exampledomain.com", "numberOfRecordSets": 2, "resourceGroup": "myResourceGroup", "tags": {}, "type": "Microsoft.Network/dnsZones" }
→
--resource-group - Specifies the Azure resource group where the DNS zone will be created.
→
--name - Specifies the DNS zone name to create.
This command adds an A record named www to the exampledomain.com DNS zone, pointing to the IP address 20.50.40.30 with a TTL of 3600 seconds.
Terminal
az network dns record-set a add-record --resource-group myResourceGroup --zone-name exampledomain.com --record-set-name www --ipv4-address 20.50.40.30 --ttl 3600
Expected OutputExpected
No output (command runs silently)
→
--record-set-name - Specifies the DNS record set name to add the record to.
→
--ipv4-address - Specifies the IPv4 address for the A record.
→
--ttl - Sets how long DNS servers cache this record.
This command shows the details of the A record named www in the exampledomain.com DNS zone to verify it was created correctly.
Terminal
az network dns record-set a show --resource-group myResourceGroup --zone-name exampledomain.com --name www
Expected OutputExpected
{ "fqdn": "www.exampledomain.com.", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/dnsZones/exampledomain.com/A/www", "name": "www", "properties": { "metadata": {}, "ttl": 3600, "aRecords": [ { "ipv4Address": "20.50.40.30" } ] }, "type": "Microsoft.Network/dnsZones/A" }
→
--name - Specifies the DNS record set name to show.
Key Concept

If you remember nothing else from this pattern, remember: Azure DNS lets you manage your domain names and their IP addresses easily in the cloud without running your own DNS servers.

Common Mistakes
Trying to add DNS records before creating the DNS zone.
DNS records must belong to an existing DNS zone; without the zone, records cannot be created.
Always create the DNS zone first using 'az network dns zone create' before adding any records.
Using incorrect resource group names or zone names in commands.
Azure commands require exact resource group and zone names; typos cause errors or create resources in wrong places.
Double-check resource group and zone names before running commands to ensure they match your Azure setup.
Not specifying TTL or using very low TTL values without reason.
TTL controls caching; very low TTL can increase DNS query traffic and slow down resolution.
Set TTL to a reasonable value like 3600 seconds unless you have a specific need for faster updates.
Summary
Create a DNS zone in Azure to start managing your domain's DNS records.
Add DNS records like A records to point domain names to IP addresses.
Verify DNS records exist and have correct values using Azure CLI commands.

Practice

(1/5)
1. What is the main purpose of Azure DNS?
easy
A. To monitor network traffic in real-time
B. To store files and documents securely
C. To run virtual machines in the cloud
D. To manage domain names and translate them to IP addresses

Solution

  1. Step 1: Understand Azure DNS role

    Azure DNS is used to manage domain names and their records inside Azure.
  2. Step 2: Identify main function

    It translates domain names into IP addresses so users can find services on the internet.
  3. Final Answer:

    To manage domain names and translate them to IP addresses -> Option D
  4. Quick Check:

    Azure DNS = Domain name management [OK]
Hint: Azure DNS handles domain names, not files or VMs [OK]
Common Mistakes:
  • Confusing DNS with storage services
  • Thinking Azure DNS runs virtual machines
  • Mixing DNS with network monitoring
2. Which of the following is the correct way to create a DNS zone in Azure CLI?
easy
A. az network dns zone create -g MyResourceGroup -n example.com
B. az dns create zone -g MyResourceGroup -n example.com
C. az network create dnszone -g MyResourceGroup -n example.com
D. az dns zone new -g MyResourceGroup -n example.com

Solution

  1. Step 1: Recall Azure CLI syntax for DNS zone creation

    The correct command uses 'az network dns zone create' with resource group and zone name.
  2. Step 2: Compare options

    Only az network dns zone create -g MyResourceGroup -n example.com matches the correct Azure CLI syntax for creating a DNS zone.
  3. Final Answer:

    az network dns zone create -g MyResourceGroup -n example.com -> Option A
  4. Quick Check:

    Correct Azure CLI DNS zone command = az network dns zone create -g MyResourceGroup -n example.com [OK]
Hint: Remember 'az network dns zone create' for DNS zones [OK]
Common Mistakes:
  • Using incorrect command verbs like 'new' or 'create zone'
  • Omitting 'network' in the command
  • Mixing up command order or parameters
3. Given this Azure CLI command:
az network dns record-set a add-record -g MyRG -z example.com -n www -a 10.0.0.1
What does this command do?
medium
A. Creates a DNS zone named 'www' in resource group MyRG
B. Creates an A record named 'www' pointing to IP 10.0.0.1 in example.com zone
C. Deletes the A record named 'www' in example.com zone
D. Adds a CNAME record pointing 'www' to 10.0.0.1

Solution

  1. Step 1: Analyze command components

    The command adds an A record ('-a') named 'www' with IP 10.0.0.1 to the DNS zone 'example.com' in resource group 'MyRG'.
  2. Step 2: Confirm record type and action

    'add-record' means creating a record, and 'a' specifies an A record (IP address).
  3. Final Answer:

    Creates an A record named 'www' pointing to IP 10.0.0.1 in example.com zone -> Option B
  4. Quick Check:

    Command adds A record 'www' with IP 10.0.0.1 [OK]
Hint: A record = IP address, add-record means create [OK]
Common Mistakes:
  • Confusing A record with CNAME
  • Thinking the command deletes records
  • Misreading '-n' as zone name instead of record name
4. You run this command to add a TXT record:
az network dns record-set txt add-record -g RG1 -z example.com -n info -v "verification=12345"
But it fails with an error. What is the likely cause?
medium
A. The '-v' parameter is invalid; it should be '-a' for TXT records
B. The record name '-n' cannot be 'info' for TXT records
C. The TXT record value must be enclosed in single quotes, not double quotes
D. The resource group name 'RG1' is missing

Solution

  1. Step 1: Check TXT record syntax

    TXT record values often require single quotes to avoid shell parsing errors.
  2. Step 2: Identify error cause

    Using double quotes can cause the shell to misinterpret the value, leading to failure.
  3. Final Answer:

    The TXT record value must be enclosed in single quotes, not double quotes -> Option C
  4. Quick Check:

    Use single quotes for TXT values to avoid errors [OK]
Hint: Use single quotes for TXT record values in CLI [OK]
Common Mistakes:
  • Using wrong parameter '-a' instead of '-v' for TXT
  • Assuming record name restrictions incorrectly
  • Ignoring resource group existence
5. You want to create a DNS zone for your domain 'myapp.com' and add two records: an A record for 'app' pointing to 192.168.1.10 and a CNAME record for 'www' pointing to 'app.myapp.com'. Which sequence of Azure CLI commands correctly achieves this?
hard
A. 1) az network dns zone create -g RG -n myapp.com
2) az network dns record-set a add-record -g RG -z myapp.com -n app -a 192.168.1.10
3) az network dns record-set cname set-record -g RG -z myapp.com -n www -c app.myapp.com
B. 1) az network dns zone create -g RG -n myapp.com
2) az network dns record-set cname add-record -g RG -z myapp.com -n app -c 192.168.1.10
3) az network dns record-set a set-record -g RG -z myapp.com -n www -a app.myapp.com
C. 1) az dns zone create -g RG -n myapp.com
2) az network dns record-set a add-record -g RG -z myapp.com -n app -a 192.168.1.10
3) az network dns record-set cname add-record -g RG -z myapp.com -n www -c app.myapp.com
D. 1) az network dns zone create -g RG -n myapp.com
2) az network dns record-set a add-record -g RG -z myapp.com -n app -a 192.168.1.10
3) az network dns record-set cname add-record -g RG -z myapp.com -n www -a app.myapp.com

Solution

  1. Step 1: Create DNS zone

    Use 'az network dns zone create' with resource group and domain name to create the zone.
  2. Step 2: Add A record for 'app'

    Use 'az network dns record-set a add-record' with correct parameters to add IP address record.
  3. Step 3: Add CNAME record for 'www'

    Use 'az network dns record-set cname set-record' to point 'www' to 'app.myapp.com'.
  4. Final Answer:

    1) az network dns zone create -g RG -n myapp.com
    2) az network dns record-set a add-record -g RG -z myapp.com -n app -a 192.168.1.10
    3) az network dns record-set cname set-record -g RG -z myapp.com -n www -c app.myapp.com
    -> Option A
  5. Quick Check:

    Zone create + A record + CNAME set-record = 1) az network dns zone create -g RG -n myapp.com
    2) az network dns record-set a add-record -g RG -z myapp.com -n app -a 192.168.1.10
    3) az network dns record-set cname set-record -g RG -z myapp.com -n www -c app.myapp.com [OK]
Hint: Use 'add-record' for A, 'set-record' for CNAME [OK]
Common Mistakes:
  • Using wrong commands like 'az dns zone create'
  • Mixing up 'add-record' and 'set-record' for CNAME
  • Assigning IP to CNAME record
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard