Hi @alabitosin58@gmail.com ,
welcome to the Microsoft Q&A Platform!
To automatically revalidate a custom domain mapped to an Azure Static Web App (SWA), you can use Azure DNS and script-based automation to periodically update the TXT record for domain ownership verification:
- Automated Revalidation with Azure DNS:
- If you manage your DNS with Azure DNS: You can use Azure CLI or PowerShell scripts to automate the re-addition of the TXT record before it expires.
- Create a script that runs periodically (such as every 5-6 months) to check if the revalidation is due.
- Use Azure CLI or Azure PowerShell within the script to update or add the TXT record required for validation.
- Deploy this script in an Azure Function or Azure Logic App to ensure it runs automatically at the desired interval.
- Here’s a simplified example of a PowerShell script to add or update a TXT record in Azure DNS:
$resourceGroupName = "YourResourceGroup" $zoneName = "yourdomain.com" $recordSetName = "_dnsauth.swa" $txtValue = "YourVerificationToken" # Authenticate with Azure Connect-AzAccount # Add or update the TXT record in Azure DNS New-AzDnsRecordSet -Name $recordSetName -RecordType TXT -ZoneName $zoneName -ResourceGroupName $resourceGroupName -Ttl 3600 -DnsRecords (New-AzDnsRecordConfig -Value $txtValue) -Force