简体   繁体   English

自动连接到最近的 Azure Cosmos DB 位置?

[英]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? 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).您可以设置首选位置,但理想情况下,我希望我的应用程序能够自动发现最近的区域并连接到该区域(并在需要时故障转移到另一个区域)。

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. EnableEndpointDiscoveryPreferredLocations允许您利用 Cosmos DB 故障转移功能。

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如果将此EnableEndpointDiscovery的值设置为 true,则 SDK 将自动发现当前的写入和读取区域,以确保根据PreferredLocations属性中指定的区域将请求发送到正确的区域

To update on this: The missing feature/switch is called ApplicationRegion which is already present in the .NET SDK.要对此进行更新:缺少的功能/开关称为ApplicationRegion ,它已存在于 .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 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM