CosmosClientOptions.ApplicationRegion Property

Definition

Gets or sets the location where the application is running. This will influence the SDK's choice for the Azure Cosmos DB service interaction.

public string ApplicationRegion { get; set; }
member this.ApplicationRegion : string with get, set
Public Property ApplicationRegion As String

Property Value

Examples

If an account is configured with multiple regions including West US, East US, and West Europe, configuring a client like the below example would result in the CosmosClient generating a sorted preferred regions based on proximity to East US. The CosmosClient will send requests to East US, if that region becomes unavailable, it will fallback to West US (second in proximity), and finally to West Europe if West US becomes unavailable.

CosmosClientOptions clientOptions = new CosmosClientOptions()
{
    ApplicationRegion = Regions.EastUS
};

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 ApplicationRegion to populate the preferred list with the account available regions ordered by geographical proximity to the indicated region. If the value of ApplicationRegion is not an available region in the account, the preferred list is still populated following the same mechanism but would not include the indicated region.

If during CosmosClient initialization, the Endpoint is not reachable, the CosmosClient will attempt to recover and obtain the account information issuing requests to all Regions ordered by proximity to the ApplicationRegion. For more granular control over the selected regions or to define a list based on a custom criteria, use ApplicationPreferredRegions instead of ApplicationRegion.

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

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

Applies to

See also