📜 ⬆️ ⬇️

Creating domain zones in AzureDns [cheat sheet]

Hi, Habr!
I want to publish a small cheat sheet on creating new domain zones in AzureDns. To my surprise, I did not find any visual editor for this in the new interface, so all actions will be performed from PowerShell.

Reworking a bunch of articles from the DNS creation guide in Azure made a slight squeeze of the right commands.

Step one


Download and install PowerShell
Switch to Azure mode:
Switch-AzureMode -Name AzureResourceManager 

Log in:
 Add-AzureAccount 

Switch to subscription:
 Select-AzureSubscription -SubscriptionName "name" 

If you do not know what name to specify, then the list of subscriptions can be obtained with the command:
 Get-AzureSubscription 

We are interested in the Name field, the data from it must be inserted into the -SubscriptionName option.
')
Read more about dns in Azure.

Step two


Create a new root zone (or get the existing one):
 $zone = New-AzureDnsZone -Name domain.com -ResourceGroupName "Group-1" 

or
 $zone = Get-AzureDnsZone -Name domain.com -ResourceGroupName "Group-1" 

Information on the created zone can be viewed with the command:
 Get-AzureDnsRecordSet –Name “@” –RecordType NS –Zone $zone 


Step Three


Add a record:
 New-AzureDnsRecordSet -Name "@" -Zone $zone -RecordType "A" -Ttl 300 | Add-AzureDnsRecordConfig -Ipv4Address "1.2.3.4" | Set-AzureDnsRecordSet 

or by zone name
 New-AzureDnsRecordSet -Name "@" –ZoneName domain.com -ResourceGroupName "Group-1" -RecordType "A" -Ttl 300 | Add-AzureDnsRecordConfig -Ipv4Address "1.2.3.4" | Set-AzureDnsRecordSet 


Read more about supported entries.

Step four


We look at the ns-servers by zone:
 Get-AzureDnsRecordSet -Zone $zone -Name "@" -RecordType NS 


And add them to your registrar.

Repeat the steps as many times as necessary. You can view the list of already added zones with the command:
 Get-AzureDnsZone -ResourceGroupName Group-1 


Add a subdomain


 New-AzureDnsZone -Name "test.domain.com" -ResourceGroupName "Group-1" New-AzureDnsRecordSet -Name "@" -ZoneName "test.domain.com" -ResourceGroupName "Group-1" -RecordType "A" -Ttl 300 | Add-AzureDnsRecordConfig -Ipv4Address "1.2.3.4" | Set-AzureDnsRecordSet $parent = Get-AzureDnsZone -Name "domain.com" -ResourceGroupName "Group-1" $child = Get-AzureDnsZone -Name "test.domain.com" -ResourceGroupName "Group-1" $child_ns_recordset = Get-AzureDnsRecordSet -Zone $child -Name "@" -RecordType NS $parent_ns_recordset = New-AzureDnsRecordSet -Zone $parent -Name "test" -RecordType NS -Ttl 3600 $parent_ns_recordset.Records = $child_ns_recordset.Records Set-AzureDnsRecordSet -RecordSet $parent_ns_recordset 


PS: and even better to use the utility of habrauser leschenko , for which he is very grateful!

Thank you for attention.

Source: https://habr.com/ru/post/265797/


All Articles