Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.77 KB

Azure_DNS_Records_via_azcli.md

File metadata and controls

67 lines (54 loc) · 1.77 KB

How to create DNS records via az-cli

If you are frequently creating DNS records, it is much easier to set up az cli to do it without having to log into the Azure Web portal.

First set up AZ CLI

  1. Install az cli from here

  2. Log in to az cli with az login

  3. Set table output as default (optional, qol)

az configure --defaults output=table
  1. List and set your subscription
az account list
az account set --subscription [SUBSCRIPTION-NAME]
  1. List and set your Location
az group list
az configure --defaults location=australiaeast
  1. List and set your Resource Group
az group list
az configure --defaults group=[RESOURCE-GROUP-NAME]

Now you can create DNS records

  1. Create DNS records with
az network dns record-set a add-record --zone-name [ZONE-NAME] --ttl 600 --record-set-name [RECORD-NAME] --ipv4-address [IP-ADDRESS]

#SHORTER
az network dns record-set a add-record --zone-name [ZONE-NAME] --ttl 600 -n [RECORD-NAME] --ip [IP-ADDRESS]

(Optional) How to delete a DNS record set

  1. List DNS records with
az network dns record-set list --zone-name [ZONE-NAME]
  1. Delete one DNS record set with
az network dns record-set a delete --zone-name [ZONE-NAME] -n [RECORD-NAME]

(Alias) Create Aliases for easy Creation

  1. Create the aliases with the zone and ttl baked in
alias azcdns="az network dns record-set a add-record --zone-name [ZONE-NAME] --ttl 600"
alias azdns="az network dns record-set list --zone-name [ZONE-NAME]"
alias azddns="az network dns record-set a delete --zone-name [ZONE-NAME]"
  1. Use them like this (create / list / delete)
az-dns-create -n [HOSTNAME] --ip [IP-ADDRESS]
az-dns-list
az-dns-delete -n [HOSTNAME]