Configure Auto‑Failover Groups
Auto‑failover groups enable you to configure a set of databases on a primary server to automatically fail over to a secondary server in a different region. This provides high availability and disaster recovery for mission‑critical workloads.
Prerequisites
- Two Azure SQL logical servers in different Azure regions.
- Azure CLI 2.0 or Azure PowerShell installed.
- Owner or Contributor role on the resource group containing the servers.
Create an Auto‑Failover Group
Use the Azure portal, Azure CLI, or PowerShell. Below is the Azure CLI method.
az sql failover-group create \
--resource-group MyResourceGroup \
--server primary-server \
--partner-server secondary-server \
--name MyFailoverGroup \
--partner-resource-group MyResourceGroup \
--partner-database secondary-db
Add Databases to the Group
After creating the group, add additional databases:
az sql failover-group set-primary \
--resource-group MyResourceGroup \
--server primary-server \
--name MyFailoverGroup \
--add-db mydb1 mydb2
Monitoring & Manual Failover
Check the health of the failover group:
az sql failover-group show \
--resource-group MyResourceGroup \
--server primary-server \
--name MyFailoverGroup
Trigger a manual failover if needed:
az sql failover-group set-secondary \
--resource-group MyResourceGroup \
--server secondary-server \
--name MyFailoverGroup
Troubleshooting
- Replication lag: Verify network latency between regions.
- Failover failed: Ensure that the secondary server is online and the firewall allows traffic from the primary.
- Permissions: Confirm you have
SQL Contributorrole on both servers.