Skip to content

Instantly share code, notes, and snippets.

@GraafG
Last active November 6, 2020 08:42
Show Gist options
  • Save GraafG/59961e637180154194994eea0661f3ae to your computer and use it in GitHub Desktop.
Save GraafG/59961e637180154194994eea0661f3ae to your computer and use it in GitHub Desktop.
Script to add CAA records to Azure DNS
#More info: https://geertdegraaf.nl/adding-caa-records-to-azure-dns
#login with Azure Account
Login-AzureRmAccount
#select subscription with Azure DNS
Get-AzureRmSubscription
Set-AzureRmContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"
#List all ResourceGroups in Subscription
Get-AzureRmResourceGroup
#List all DNS zones in ResourceGroup
Get-AzureRmDnsZone -ResourceGroupName %ResourceGroupName%
#List all CAA records for DNS zone (replace DNSExample and example.com)
Get-AzureRmDnsRecordSet -ResourceGroupName DNSExample -ZoneName example.com -RecordType CAA
#Preparing
records
$caaRecords = @()
$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "iodef" -CaaValue "mailto:admin@example.com"
$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "issue" -CaaValue "letsencrypt.org"
#for wildcard uncomment next line
#$caaRecords += New-AzureRmDnsRecordConfig -CaaFlag "0" -CaaTag "issuewild" -CaaValue "letsencrypt.org"
#Adding CAA records
New-AzureRmDnsRecordSet -Name "@" -RecordType CAA -ZoneName "example.com" -ResourceGroupName DNSExample -Ttl 3600 -DnsRecords $caaRecords
#Verify CAA records are added in the DNS zone (replace DNSExample and example.com)
Get-AzureRmDnsRecordSet -ResourceGroupName DNSExample -ZoneName example.com -RecordType CAA
@GraafG
Copy link
Author

GraafG commented Nov 20, 2019

Can you try to use Powershell ISE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment