Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to add CAA records to Azure DNS
#More info:
#login with Azure Account
#select subscription with Azure DNS
Set-AzureRmContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"
#List all ResourceGroups in Subscription
#List all DNS zones in ResourceGroup
Get-AzureRmDnsZone -ResourceGroupName %ResourceGroupName%
#List all CAA records for DNS zone
Get-AzureRmDnsRecordSet -ResourceGroupName DNSExample -ZoneName -RecordType CAA
$caaRecords = @()
$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "iodef" -CaaValue ""
$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "issue" -CaaValue ""
#for wildcard uncomment next line
#$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "issuewild" -CaaValue ""
#Adding CAA records
New-AzureRmDnsRecordSet -Name "@" -RecordType CAA -ZoneName "" -ResourceGroupName DNSExample -Ttl 3600 -DnsRecords $caaRecords
#Verify CAA records are added in the DNS zone
Get-AzureRmDnsRecordSet -ResourceGroupName DNS -ZoneName -RecordType CAA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.