Always On: Availability Groups and FCIs
Configure Always On availability groups on Managed Instance and Azure VMs. Set up Failover Cluster Instances for SQL Server on Azure VMs.
Always On technologies
Always On Availability Groups (AGs) are like having a team of scribes copying the same document. One scribe (primary) writes, and the others (secondaries) make exact copies in real time. If the primary scribe is sick, a secondary takes over immediately.
Failover Cluster Instances (FCIs) are like a shared office β one person works at the desk at a time, but if they leave, someone else sits down and picks up exactly where they left off. The desk (shared storage) stays the same.
Always On Availability Groups
AG architecture on Azure VMs
| Component | Purpose |
|---|---|
| Primary replica | Handles all read-write workloads |
| Secondary replicas | Receive replicated data; can be readable |
| Listener | Virtual network name + IP β applications connect here |
| Synchronous mode | Zero data loss (RPO = 0), slight latency |
| Asynchronous mode | Better performance, possible data loss (RPO > 0) |
Setting up AGs on Azure VMs
- Create a Windows Server Failover Cluster (WSFC) across 2+ Azure VMs
- Enable Always On in SQL Server Configuration Manager
- Create the AG β define primary and secondary replicas
- Configure the listener β Azure Load Balancer required for the VIP
- Add databases to the AG
-- Create the Availability Group
CREATE AVAILABILITY GROUP NorthStarAG
WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY)
FOR DATABASE NorthStarERP, NorthStarHR
REPLICA ON
'SQL-VM-1' WITH (
ENDPOINT_URL = 'TCP://SQL-VM-1:5022',
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
FAILOVER_MODE = AUTOMATIC,
SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY)),
'SQL-VM-2' WITH (
ENDPOINT_URL = 'TCP://SQL-VM-2:5022',
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
FAILOVER_MODE = AUTOMATIC,
SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY));
-- Create the listener
ALTER AVAILABILITY GROUP NorthStarAG
ADD LISTENER 'NorthStarAGListener' (
WITH IP ((N'10.0.1.100', N'255.255.255.0')),
PORT = 1433);
Azure Load Balancer for AG listener
On Azure VMs, the AG listener requires an Azure Load Balancer (or distributed network name for Windows Server 2019+):
- Load Balancer provides the floating virtual IP
- Health probe on port 59999 detects which VM is the primary
- Only the primary responds to the probe β traffic routes there
- Alternative: Windows Server 2019+ supports Distributed Network Name (DNN) β no load balancer needed, simpler setup
AGs on Managed Instance
MI uses AGs internally for built-in HA (Business Critical tier). For cross-region DR:
- MI failover groups use distributed AG technology under the hood
- You donβt configure AGs directly on MI β failover groups handle it
- The MI link (to on-prem) also uses distributed AG technology
Failover Cluster Instances (FCIs)
FCIs provide instance-level failover β the entire SQL Server instance fails over to another node.
FCI architecture on Azure VMs
| Component | Purpose |
|---|---|
| Active node | Runs the SQL Server instance |
| Passive node(s) | Stand by, ready to take over |
| Shared storage | Azure Shared Disks, Storage Spaces Direct, or Azure Premium File Share |
| WSFC | Windows cluster manages failover detection |
Shared storage options
| Storage | Performance | Availability Zones | Complexity |
|---|---|---|---|
| Azure Shared Disks | Good (Premium SSD) | Limited (zone constraints) | Low |
| Storage Spaces Direct (S2D) | Excellent (local NVMe) | Yes (cross-zone) | High |
| Azure Premium File Share | Good | Yes (ZRS) | Low |
AG vs FCI comparison
| Feature | Availability Groups | Failover Cluster Instances |
|---|---|---|
| Failover scope | Database-level | Instance-level (all databases) |
| Shared storage | No (each replica has own storage) | Yes (required) |
| Readable secondaries | Yes | No (passive nodes can't serve queries) |
| Multiple databases | Selected databases join the AG | All databases on the instance |
| System databases | Not replicated | Shared (on shared storage) |
| Azure platform | SQL on VMs (full), MI (built-in) | SQL on VMs only |
| SQL Server edition | Enterprise (Standard with 1 DB limitation) | Enterprise or Standard |
Kenji needs database-level HA with readable secondaries for offloading report queries on Azure VMs. Which solution should he implement?
π¬ Video coming soon
Next up: Log Shipping and HA/DR Operations β configure log shipping and manage HA/DR monitoring and troubleshooting.