Overview of Azure SQL Database failover groups
Failover groups provide a disaster recovery solution for your Azure SQL databases by enabling automatic or manual failover of a set of databases to a secondary region. This document explains how to create, manage, and configure failover groups for Azure SQL Database.
Key Concepts
- Failover Group: A collection of Azure SQL databases in one or more logical servers that can be failed over to a secondary server in a different region.
- Primary Server: The server hosting the primary replicas of the databases in the failover group.
- Secondary Server: The server in a different Azure region hosting the secondary replicas of the databases in the failover group.
- Failover Policy: Defines the conditions under which a failover is initiated (automatic or manual).
- Read-Write Listener: A connection endpoint that is always available and redirects traffic to the current primary replica.
- Read-Only Listener: A connection endpoint that is always available and redirects read-only traffic to the current secondary replica (if configured).
Benefits
- Business Continuity: Ensures your applications remain available even in the event of a regional outage.
- Disaster Recovery: Provides a robust mechanism for recovering your databases in a different geographic location.
- Simplified Management: Manages high availability and disaster recovery for multiple databases as a single unit.
- Seamless Failover: Automatic failover options minimize downtime and manual intervention.
Creating a Failover Group
You can create a failover group using the Azure portal, Azure CLI, Azure PowerShell, or REST API. Here's a high-level overview of the steps:
- Navigate to your primary Azure SQL server in the Azure portal.
- Under the 'High Availability' section, select 'Failover groups'.
- Click 'Create failover group'.
- Configure the failover group name, secondary server, and databases to include.
- Review and create the failover group.
Managing a Failover Group
Once created, you can manage your failover group through the Azure portal or programmatically:
- Initiate Failover: Manually trigger a failover to the secondary region.
- Configure Failover Policy: Adjust the automatic failover grace period and retry intervals.
- Add/Remove Databases: Modify the set of databases included in the failover group.
- Change Secondary Server: Re-point the failover group to a different secondary region or server.
- Configure Read-Only Access: Enable and manage the read-only listener.
Connecting to Databases in a Failover Group
Applications should connect to the read-write listener endpoint of the failover group. This endpoint automatically directs connections to the current primary database, regardless of whether a failover has occurred. The listener's hostname remains the same.
Example connection string using the listener endpoint:
Server=tcp:your_failover_group_listener.database.windows.net;Database=your_database;User ID=your_user;Password=your_password;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Monitoring and Alerts
Azure SQL Database provides metrics and logs that you can use to monitor the health and status of your failover groups. Configure alerts to be notified of important events, such as failover initiations or errors.