Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preferred locations in Cosmos DB SDK v3

In CosmosDB SDK v2 it is possible to setup preferred locations during client creation (via ConnectionPolicy.PreferredLocations setting). However, I don't see similar setting in Cosmos DB SDK v3. As per my understanding, the closest setting in v3 is CosmosClientOptions.ApplicationRegion, but it allows to provide single region only.

Is there a way to to setup list of preferred locations in SDK v3?

like image 667
maxvasil Avatar asked Jan 18 '26 23:01

maxvasil


1 Answers

V3 SDK takes a different approach. By specifying the ApplicationRegion (the region where your app is actually running), it will automatically populate the priority of regions based on proximity and account availability (the regions your account is provisioned to) to optimize latency.

If your app runs in West US and your Cosmos DB account is in East US, Europe, and West US, when you set the ApplicationRegion to West US, it will automatically create the preferred list as West US, East US, and Europe (order of distance).

You just need to focus on defining which region your application runs.

like image 73
Matias Quaranta Avatar answered Jan 20 '26 21:01

Matias Quaranta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!