Azure PowerShell Version 1.0 has great benefits, and also has many breaking changes. Since I wrote about moving my DNS to Azure, things have evolved. This is a post about updating an IPV4 on a Naked Domain type A RecordSet.
Most of breaking changes are minor. If your script leveraged Azure Resource Manager (ARM), start by replacing ‘-Azure‘ with ‘-AzureRm‘. This change was made because the Switch-AzureMode CmdLet was removed.
Updating a Naked Domain RecordSet
First we need to login to the Azure Resource Manager account by specifying the name of the Subscription that we want to work with.
Login-AzureRmAccount -SubscriptionName 'Visual Studio Ultimate with MSDN'
Then we need to get the DNS Zone that we want to modify.
$zone = Get-AzureRmDnsZone -Name 'alexandrebrisebois.com' ` -ResourceGroupName 'BriseboisDNS'
At this point we can review the Name Servers (NS) records associated with our DNS Zone. Note that this is to satisfy my personal curiosity.
$recordSet = Get-AzureRmDnsRecordSet -Name '@' ` -Zone $zone ` -RecordType NS # output variable PS C:\Users\a> $recordSet Name : @ ZoneName : alexandrebrisebois.com ResourceGroupName : BriseboisDNS Ttl : 3600 Etag : 5a5efd2b-9084-4460-883c-8eafdcc33b17 RecordType : NS Records : {ns1-05.azure-dns.com, ns2-05.azure-dns.net, ns3-05.azure-dns.org, ns4-05.azure-dns.info} Tags : {}
Now using the DNS Zone, we can retrieve the RecordSet for our Naked Domain.
$recordSet = Get-AzureRmDnsRecordSet -Name '@' ` -Zone $zone ` -RecordType A # output variable PS C:\Users\a> $recordSet Name : @ ZoneName : alexandrebrisebois.com ResourceGroupName : BriseboisDNS Ttl : 60 Etag : 5ec783b9-515c-4193-97f4-c60f7ce3877b RecordType : A Records : {104.43.142.33} Tags : {}
The goal of this post is to update the IPV4 of this specific RecordSet so that it points to 168.61.152.29 instead of 104.43.142.33. So lets start by adding the new IPV4.
Add-AzureRmDnsRecordConfig -RecordSet $recordSet ` -Ipv4Address '168.61.152.29' $recordSet = Set-AzureRmDnsRecordSet -RecordSet $recordSet
Then we can remove the old IPV4 fron the RecordSet.
Remove-AzureRmDnsRecordConfig -RecordSet $recordSet ` -Ipv4Address '104.43.142.33' $recordSet = Set-AzureRmDnsRecordSet -RecordSet $recordSet
Now it’s time to verify that everything is updated properly. Since we’ve played with DNS entries, it’s always good to flush our local DNS cache before we try anything else. This can be done by using a command prompt and that ipconfig /flushdns command.
Resolve-DnsName -Name 'alexandrebrisebois.com' -Type ALL Name Type TTL Section PrimaryServer NameAdministrator SerialNumber ---- ---- --- ------- ------------- ----------------- ------------ alexandrebrisebois.com SOA 3600 Answer edge1.azuredns-cloud.net msnhst.microsoft.com 13 Name : alexandrebrisebois.com QueryType : A TTL : 60 Section : Answer IP4Address : 168.61.152.29
Note that we can also use online tools like http://www.digwebinterface.com to explore and verify our DNS entries.