Skip to content

Instantly share code, notes, and snippets.

@bluedoors
Forked from animetauren/ACMESharpAzureDNS.ps1
Last active January 6, 2017 05:21
Show Gist options
  • Save bluedoors/db9f6a4f9bfd8f7cda0926a2419584b8 to your computer and use it in GitHub Desktop.
Save bluedoors/db9f6a4f9bfd8f7cda0926a2419584b8 to your computer and use it in GitHub Desktop.
ACMESharp DNS Challenge with Azure DNS
#Deal with the challenge for each SAN
$i=0
foreach ($subDomain in $domains) {
$i++
$alias = 'dns' + $i
New-ACMEIdentifier -Dns $subDomain -Alias $alias
$completedChallenge = Complete-ACMEChallenge $alias -ChallengeType dns-01 -Handler manual
$dnsRRName = ($completedChallenge.Challenges | Where-Object {$_.Type -eq "dns-01"}).Challenge.RecordName
$dnsRRName = $dnsRRName.TrimEnd(".example.com")
$dnsRRValue = ($completedChallenge.Challenges | Where-Object {$_.Type -eq "dns-01"}).Challenge.RecordValue
# Set the DNS records in Azure
$Records = @()
$Records += New-AzureRmDnsRecordConfig -Value $dnsRRValue
$RecordSet = New-AzureRmDnsRecordSet -Name $dnsRRName -RecordType TXT -ResourceGroupName $RGName -TTL 3600 -ZoneName "example.com" -DnsRecords $Records
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment