Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What connection string to use for Azure SQL DB using Active Geo Replication?

I have a database in SQL Azure which is being actively replicated to 2 different regions. They are both read-only accessible (tested from SQL management studio by connecting to their respective servers) but what connection string do I need to use for my application to use automatic failover/fallback and/or to use the readonly instance for read and the master instance for write?

like image 509
IvanL Avatar asked Jun 16 '15 11:06

IvanL


People also ask

What is the connection string for Azure SQL Database?

This is connection string that worked for me. Server=tcp:[serverName]. database.windows.net;Database=myDataBase; User ID=[LoginForDb]@[serverName];Password=myPassword;Trusted_Connection=False; Encrypt=True; This also works.

How do you set up geo-replication in Azure?

In the Azure portal, browse to the primary database in the geo-replication partnership. Scroll to Data management, and then select Replicas. In the Geo replicas list, select the database you want to become the new primary, select the ellipsis, and then select Forced failover. Select Yes to begin the failover.

Where is SQL Server connection string Azure?

Navigate to the database blade in the Azure portal and, under Settings, select Connection strings.


2 Answers

You can now create a failover group and set up auto-failover (currently in preview) and then you will have a read/write listener connection string

Go to the Azure SQL Server (not a specific database) -> Failover Groups -> Create and fill in the required info - servers, DBs and policy

After the group is created you will have a listener connection string you can use across both DBs in the failover group configuration details

For more info, please check https://docs.microsoft.com/en-us/azure/sql-database/sql-database-geo-replication-overview#auto-failover-group-capabilities

like image 106
DivineOps Avatar answered Oct 24 '22 22:10

DivineOps


Your application has to connect in the same way to the readable secondaries as you did from SSMS: You have to use the connection string of the server that holds to replica.

Failovers can be triggered use T-SQL commands, PowerShell and through the management portal. Check these two documentation articles:

Active Geo-Replication for Azure SQL Database Terminate a Continuous Copy Relationship

like image 37
Jan Engelsberg Avatar answered Oct 24 '22 23:10

Jan Engelsberg