Udostępnij za pośrednictwem


CosmosClientOptions.ApplicationPreferredRegions Property

Definition

Gets and sets the preferred regions for geo-replicated database accounts in the Azure Cosmos DB service.

public System.Collections.Generic.IReadOnlyList<string> ApplicationPreferredRegions { get; set; }
member this.ApplicationPreferredRegions : System.Collections.Generic.IReadOnlyList<string> with get, set
Public Property ApplicationPreferredRegions As IReadOnlyList(Of String)

Property Value

Examples

CosmosClientOptions clientOptions = new CosmosClientOptions()
{
    ApplicationPreferredRegions = new List<string>(){ Regions.EastUS, Regions.WestUS }
};

CosmosClient client = new CosmosClient("endpoint", "key", clientOptions);

Remarks

During the CosmosClient initialization the account information, including the available regions, is obtained from the Endpoint. The CosmosClient will use the value of ApplicationPreferredRegions to populate the preferred list with the account available regions that intersect with its value. If the value of ApplicationPreferredRegions contains regions that are not an available region in the account, the values will be ignored. If the these invalid regions are added later to the account, the CosmosClient will use them if they are higher in the preference order.

If during CosmosClient initialization, the Endpoint is not reachable, the CosmosClient will attempt to recover and obtain the account information issuing requests to the regions in ApplicationPreferredRegions in the order that they are listed.

See also Diagnose and troubleshoot the availability of Cosmos SDKs for more details.

This configuration is an alternative to ApplicationRegion, either one can be set but not both.

Applies to