Why this path
Tier 1 databases with strict downtime limits often already run an AG. Adding an Azure replica turns the migration into a planned AG failover — the same operation the team already practises.
It's also a good two-step transformation: Azure as DR first, then Azure as primary.
1. Network
- ExpressRoute (preferred) or site-to-site VPN; measure latency (async commit over WAN; sync only if latency is low, < ~5 ms).
- Open the mirroring endpoint port (5022), SQL port (1433), and cluster ports between sites.
- DNS: Azure VMs resolve on-premises AD and vice versa.
2. Choose the topology
| Topology | Description | Notes |
|---|---|---|
| Stretched WSFC (one cluster, nodes in both sites) | Add the Azure VM as a node and a replica | Quorum design is critical; set Azure node vote to 0 at first |
| Distributed AG | Separate cluster in Azure with its own AG; DAG links the two | Cleaner separation, different domains possible, easier final cut |
For migration, the distributed AG is often simpler: when you're done, you just drop the on-premises side.
3. Add the Azure replica (stretched cluster example)
ALTER AVAILABILITY GROUP AG_Sales ADD REPLICA ON 'VM-SQL-AZ1'
WITH (ENDPOINT_URL = 'TCP://vm-sql-az1.corp.local:5022',
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, FAILOVER_MODE = MANUAL,
SEEDING_MODE = AUTOMATIC, SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY));
-- on the Azure VM
ALTER AVAILABILITY GROUP AG_Sales JOIN;
ALTER AVAILABILITY GROUP AG_Sales GRANT CREATE ANY DATABASE;
For very large databases, seed by backup/restore (WITH NORECOVERY) instead of automatic seeding over the WAN.
Add an Azure subnet IP to the AG listener (multi-subnet listener) so clients find the primary in either site.
4. Phase 1: Azure as DR
- Run as an async DR replica for weeks; test read-only routing and a DR drill.
- Build the second Azure replica (other availability zone) so Azure has HA before it becomes primary.
5. Phase 2: make Azure primary
- Switch the Azure replica to synchronous commit temporarily (if latency allows) so the failover is lossless — or stop the app and wait for zero lag.
- Planned failover to the Azure replica:
ALTER AVAILABILITY GROUP AG_Sales FAILOVER; -- on the Azure replica (synchronous, synchronized)
With async only: stop the app, confirm last_hardened_lsn matches, then FORCE_FAILOVER_ALLOW_DATA_LOSS (no loss if fully caught up).
3. Clients with MultiSubnetFailover=True reconnect to the listener in Azure.
4. Keep on-premises replicas as async secondaries (fallback) for an agreed period.
5. Remove on-premises replicas and nodes; move cluster quorum to a cloud witness.
6. Watch-outs
- Apps still on-premises now talk to Azure over the WAN: move the apps in the same wave or check latency.
- Licensing: one free passive replica for HA and one for DR with SA; active replicas need licences.
Tip
Check
MultiSubnetFailover=Truein every connection string before the cutover. Clients without it can take up to 20+ seconds per connection attempt to find the new primary.