In a previous article I described how to configure an Azure SQL database failover group for high availability across multiple regions.
But what if you want to limit network traffic to a database in this failover group to only your private networks?
In this article I show how to make a SQL database failover group reachable via the Private Link service and make sure the database stays reachable after a failover.
In a previous article I described how to configure
an Azure SQL database failover group for high availability across multiple regions.
But what if you want to limit network traffic to a database in this failover group to only your private networks?
In this article I show how to make a SQL database failover group reachable via the
Private Link service and make sure the database stays reachable after a failover.
For each of the SQL servers in the failover group we need to add a private link.
First retrieve the id of the server using the az sql server show command.
Specify the SQL server resource id and the name of the subnet that are on both sides of the connection.
Do the same for the other SQL server in the failover group.
Creating the private DNS zone
When any application connected to the private network resolves the DNS name
hompus-db-group.database.windows.net the response will contain the external IP-address.
This defeats the purpose of the network and endpoint.
A linked private DNS zone allows virtual machines on the virtual network to be automatic added as entries in the DNS zone.
This is not relevant for the private link DNS zone, so this option can be disabled.
The next step is to add the private endpoints to the DNS zone.
This does not require knowledge of the actual IP-addresses that have been assigned on the network.
With the az network private-endpoint dns-zone-group create command the endpoint is registered,
and the private IP-address will be resolved.
Resolving the private endpoint
After the registration is done, any application connected to the private network will resolve the DNS name
hompus-db-group.database.windows.net to the internal IP-address.
The DNS name for hompus-db-group.secondary.database.windows.net will point to the other server in the failover group.
After executing a failover, to DNS entries have swapped servers.
This proves that connections on the virtual network will use the private link to the SQL database,
no matter which one is the current primary or secondary in the failover group.
It is also possible to connect virtual networks from other regions to the same SQL failover group,
just iterate the same steps for each region.