你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

CosmosClientOptions.AvailabilityStrategy Property

Definition

Availability Strategy to be used for periods of high latency

public Microsoft.Azure.Cosmos.AvailabilityStrategy AvailabilityStrategy { get; set; }
member this.AvailabilityStrategy : Microsoft.Azure.Cosmos.AvailabilityStrategy with get, set
Public Property AvailabilityStrategy As AvailabilityStrategy

Property Value

Examples

An example on how to set an availability strategy custom serializer.

CosmosClient client = new CosmosClientBuilder("connection string")
.WithApplicationPreferredRegions(
   new List<string> { "East US", "Central US", "West US" } )
.WithAvailabilityStrategy(
   AvailabilityStrategy.CrossRegionHedgingStrategy(
   threshold: TimeSpan.FromMilliseconds(500),
   thresholdStep: TimeSpan.FromMilliseconds(100)
))
.Build();

Remarks

The availability strategy in the example is a Cross Region Hedging Strategy. These strategies take two values, a threshold and a threshold step.When a request that is sent out takes longer than the threshold time, the SDK will hedge to the second region in the application preferred regions list. If a response from either the primary request or the first hedged request is not received after the threshold step time, the SDK will hedge to the third region and so on.

Applies to