Last active
November 6, 2020 08:42
-
-
Save GraafG/59961e637180154194994eea0661f3ae to your computer and use it in GitHub Desktop.
Script to add CAA records to Azure DNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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:[email protected]" | |
$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 |
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
Hey GraafG, ive been hiitting a darn brick wall on the #Adding CAA records line tells me: Can not perform requested operation on nested resource. Parent resource 'bpcos.cf' not found...
would you lend me a helping hand trying to debug what``ve missed ?
cheers, thank you for that tutorial and code :)