Geo-Replication and Failover Groups
Configure active geo-replication for Azure SQL Database and failover groups for automatic cross-region disaster recovery.
Cross-region disaster recovery
Active geo-replication is like having a live copy of your office in another city. Everything you write in your primary office is instantly copied to the remote office. If your primary burns down, the remote office has everything.
Failover groups take it further β they add a shared phone number (listener endpoint). Callers always reach the active office automatically. When you fail over, the phone number follows the active office.
Active geo-replication
Available for Azure SQL Database only (not MI, not VMs):
How it works
- Primary database in Region A
- Create up to 4 readable secondary databases in other regions
- Asynchronous replication β RPO typically under 5 seconds
- Secondaries are readable (offload read queries)
- Failover is manual β you initiate it
# Create a geo-secondary
az sql db replica create \
--resource-group NorthStarRG \
--server northstar-sql-primary \
--name NorthStarERP \
--partner-server northstar-sql-secondary \
--partner-resource-group NorthStarRG-DR
-- Check replication status
SELECT
partner_server, partner_database, replication_state_desc,
last_replication, replication_lag_sec
FROM sys.dm_geo_replication_link_status;
Failover
# Manual failover (secondary becomes primary)
az sql db replica set-primary \
--resource-group NorthStarRG-DR \
--server northstar-sql-secondary \
--name NorthStarERP
Failover groups
Failover groups provide automatic failover and a listener endpoint that applications use β no connection string changes needed during failover.
Geo-replication vs failover groups
| Feature | Active Geo-Replication | Failover Groups |
|---|---|---|
| Platform | SQL Database only | SQL Database and Managed Instance |
| Automatic failover | No (manual only) | Yes (configurable) |
| Listener endpoint | No | Yes β read-write and read-only endpoints |
| Max secondaries | 4 per database | 1 secondary region |
| Multiple databases | Individual database | Group of databases fail over together |
| Connection string | Must update on failover | No change β listener redirects |
| Grace period | N/A | Configurable (min 1 hour) |
| RPO | < 5 seconds | < 5 seconds |
Setting up a failover group
# Create failover group for SQL Database
az sql failover-group create \
--resource-group NorthStarRG \
--server northstar-sql-primary \
--name northstar-fog \
--partner-server northstar-sql-secondary \
--partner-resource-group NorthStarRG-DR \
--failover-policy Automatic \
--grace-period 1
# Add databases to the group
az sql failover-group update \
--resource-group NorthStarRG \
--server northstar-sql-primary \
--name northstar-fog \
--add-db NorthStarERP
Failover group endpoints
| Endpoint | Pattern | Connects To |
|---|---|---|
| Read-write listener | northstar-fog.database.windows.net | Current primary |
| Read-only listener | northstar-fog.secondary.database.windows.net | Current secondary |
Priyaβs setup at ScaleWave: Application connection strings point to the failover group listener, not the individual server. When failover happens, the listener automatically routes to the new primary β zero application changes.
Failover policies
| Policy | Behaviour |
|---|---|
| Automatic | Azure detects primary outage and fails over after grace period |
| Manual | You initiate failover explicitly |
| Grace period | Minimum time before automatic failover (1+ hours) β prevents false positives |
Managed Instance failover groups
MI failover groups work similarly but with key differences:
- Secondary MI must be in a different region
- VNet peering or VPN required between MI subnets
- All databases on the MI fail over together (instance-level, not per-database)
- DNS alias handles connection redirection
Exam tip: failover group vs geo-replication
The exam loves this comparison. Quick decision:
- Need automatic failover? β Failover group
- Need listener endpoint (no connection string change)? β Failover group
- Need 4 readable secondaries? β Geo-replication
- Need MI DR? β Failover group (geo-replication doesnβt support MI)
- Need per-database granularity? β Geo-replication (failover groups are all-or-nothing)
Priya needs Azure SQL Database DR that fails over automatically with no application connection string changes. Which solution should she configure?
π¬ Video coming soon
Next up: Always On: Availability Groups and FCIs β configure Always On for SQL Managed Instance and Azure VMs.