CosmosClientBuilder.WithApplicationPreferredRegions Method

Definition

Set the preferred regions for geo-replicated database accounts in the Azure Cosmos DB service.

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithApplicationPreferredRegions (System.Collections.Generic.IReadOnlyList<string> applicationPreferredRegions);
member this.WithApplicationPreferredRegions : System.Collections.Generic.IReadOnlyList<string> -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithApplicationPreferredRegions (applicationPreferredRegions As IReadOnlyList(Of String)) As CosmosClientBuilder

Parameters

applicationPreferredRegions
IReadOnlyList<String>

A list of preferred Azure regions used for SDK to define failover order.

Returns

The current CosmosClientBuilder.

Examples

The example below creates a new CosmosClientBuilder with a of preferred regions.

CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder(
    accountEndpoint: "https://testcosmos.documents.azure.com:443/",
    authKeyOrResourceToken: "SuperSecretKey")
.WithApplicationPreferredRegions(new[] {Regions.EastUS, Regions.EastUS2});
CosmosClient client = cosmosClientBuilder.Build();

Remarks

This function is an alternative to WithApplicationRegion(String), either one can be set but not both.

Applies to

See also