Storage Failover DNS mapping using Azure policy

Suraj Singh Thakur 21 Reputation points
2025-06-03T10:09:02.4533333+00:00

Need a plan for storage failover scenario, how to update the secondary private endpoint in private DNS zone using azure policy?

Please suggest some work around in terms of automating the update of DNS mapping in storage failover.

We are following this doc https://learn.microsoft.com/en-us/azure/storage/common/storage-failover-private-endpoints but this doesn't tell us about the where azure policy is handling the DNS mapping.

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,015 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marcin Policht 49,715 Reputation points MVP Volunteer Moderator
    2025-06-03T11:29:56.51+00:00

    The Microsoft documentation explains what happens during failover but not how to automate DNS updates using Azure Policy, because Azure Policy is not designed to perform resource updates or runtime automation tasks like DNS record changes. Azure Policy is a compliance and governance tool, not an automation tool. It evaluates resources at creation or modification time, not during failover. Policies can, for example, audit if a private DNS zone exists or has a required A record, deny deployment if criteria are not met, but not update or change DNS records when failover happens.

    To handle automatic DNS updates after a failover event, consider this automation plan using Azure-native tools:

    1. Detect failover

    Use Azure Resource Graph, Azure Monitor alert, or log-based queries to detect a failover. This could be:

    • Blob Storage serviceStats or health metrics.
    • Event Grid (if you have a health probe monitoring solution).
    • Or use Get-AzStorageAccountFailoverReplicationPolicyStatus periodically.
    1. Trigger Automation runbook or Logic App

    When failover is detected trigger an Azure Automation Runbook, Logic App, or Function App.

    1. Update the DNS mapping

    In the runbook or function:

    • Use PowerShell or Azure CLI to:
      • Get the new private IP of the secondary endpoint.
      • Update the A record in the private DNS zone.
    # Example PowerShell snippet
    $dnsZone = "privatelink.blob.core.windows.net"
    $recordName = "<storageaccountname>"
    $resourceGroup = "<dns-zone-resource-group>"
    
    # Get private endpoint IP
    $privateEndpoint = Get-AzPrivateEndpoint -Name "<secondary-endpoint-name>" -ResourceGroupName "<resource-group>"
    $ip = $privateEndpoint.CustomDnsConfigs[0].IpAddresses[0]
    
    # Update A record
    Remove-AzPrivateDnsRecordSet -Name $recordName -ZoneName $dnsZone -ResourceGroupName $resourceGroup -Force
    New-AzPrivateDnsRecordSet -Name $recordName -ZoneName $dnsZone -ResourceGroupName $resourceGroup -RecordType A -Ttl 3600 -DnsRecords (New-AzPrivateDnsRecordConfig -IPv4Address $ip)
    

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.