Cosmos DB Geo-replication - SQL on the edge episode 14
- Reducing read latency: you can place read copies of the database close to users locations.
- Graceful DR Degradation: if you have multiple geo-replicated regions you can set priorities to failover first to a region close to your main user base, then another a bit further and so on.
- Data Sovereignty: Cosmos DB offers geo-fencing by allowing the user to specify the failover regions. For example, if your data is not allowed to leave Canada, then you can setup your database to only permit failover between Canada Central and Canada East. This way, even in the event of a disaster, you know that you are compliant with your regulatory requirements.
// create a connection policy object
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
//set the proper regions
connectionPolicy.PreferredLocations.Add(LocationNames.CanadaCentral); // first preference
connectionPolicy.PreferredLocations.Add(LocationNames.CanadaEast); // second preference
// initialize connection with your endpoint, your access key and the policy object we just created
DocumentClient docClient = new DocumentClient(
https://mycosmosdb.documents.azure.com:443/,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
connectionPolicy);
// test the connection
await docClient.OpenAsync();
Demo Now that we have a good understanding of Cosmos DB's geo-replication, let's check out a demo of setting up the geo-replication on the Azure Portal and test the impact of using a closer read-only copy of the database for lower latency queries. Let's check it out!
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
GNU screen utility for DBAs

GNU screen utility for DBAs
Aug 29, 2016 12:00:00 AM
5
min read
How to Fix the “There is not enough space on the disk” Azure SQL Data Sync Error

How to Fix the “There is not enough space on the disk” Azure SQL Data Sync Error
Jul 28, 2022 12:00:00 AM
2
min read
Trying out Large Language Models with Azure OpenAI Service

Trying out Large Language Models with Azure OpenAI Service
Aug 17, 2023 12:00:00 AM
5
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.