silent
silent

Reputation: 16148

Automatically connect to closest Azure Cosmos DB location?

Is there a way, preferable in the Python SDK, but also just generally with any SDK/language or even just over plain HTTPS, to automatically connect to the closest region (by latency or some other metric) of a geo-replicated Azure Cosmos DB?

You can set the preferred_locations, but ideally I would like my app to automatically discover which region is the closest and connect to that (and fail over to another one if needed).

Upvotes: 1

Views: 659

Answers (2)

silent
silent

Reputation: 16148

To update on this: The missing feature/switch is called ApplicationRegion which is already present in the .NET SDK. There is now a feature request on GitHub to add this to the Python SDK as well: https://github.com/Azure/azure-sdk-for-python/issues/15685

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222582

As i know only way is to set the prefered location, preferredLocations must be specified for high availability.

EnableEndpointDiscovery along with PreferredLocations allows you to leverage Cosmos DB failover capabilities.

If you set the value of this EnableEndpointDiscovery is true, the SDK will automatically discover the current write and read regions to ensure requests are sent to the correct region based on the regions specified in the PreferredLocations property

Upvotes: 0

Related Questions