question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarify docs for CosmosClientOptions.ApplicationRegion

See original GitHub issue

The documentation for CosmosClientOptions.ApplicationRegion can be more explicit, especially in the fallback case. This will avoid confusion with the other setting, ApplicationPreferredRegions that is listed as an alternative

According to the remarks section (copy-pasted here for convenience):

Also SDK auto-selects fallback geo-replicated regions for high availability.

It should be clarified that the fallback actually happens based on proximity, as is described in this how-to.

This can be verified for example with the following Linqpad query:

#load "config" // load configuration such as dbName etc.

var options = new CosmosClientOptions();
options.ApplicationRegion = Regions.SwitzerlandNorth; // not available location on our Cosmos

var client = new CosmosClient(endpoint, servicePrincipal, options); // Cosmos account has WestUS and EastUS
var container = client.GetContainer(dbName, containerName);
client = new CosmosClient(endpoint, servicePrincipal, options);
container = client.GetContainer(dbName, containerName);

var response = await container.ReadItemAsync<object>(documentId, new PartitionKey(partitionId));
response.Diagnostics.GetContactedRegions().Dump(); // EastUS was chosen, based on proximity

For comparison, if we were to set the ApplicationPreferredRegions property instead, we would have contacted “WestUS”- our primary location.

From a quick search on StackOverflow, other users seem to have been confused by that (e.g. here and here)

Proposed changes

Summary Get or set the application location. This will affect the choice of the SDK for Azure Cosmos DB service interaction.

Remarks When this property is specified, the SDK prefers the region to perform operations. When the region specified is not available, SDK auto-selects fallback geo-replicated regions based on proximity for high availability. When this property is not specified, the SDK uses the write region as the preferred region for all operations, see troubleshooting SDK availability for more details.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Sep 15, 2021

@spygi Thanks for reporting, this item is now in the backlog, we can address it as we get time available. These texts are also coming off the files in this repo, so you could also send a PR to suggest the edit if you with: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs#L99-L109

0reactions
spygicommented, Sep 21, 2021

Done @ealsur

Read more comments on GitHub >

github_iconTop Results From Across the Web

CosmosClientOptions.ApplicationRegion Property
Gets or sets the location where the application is running. This will influence the SDK's choice for the Azure Cosmos DB service interaction....
Read more >
Cosmos DB - Should I set CosmosClientOptions. ...
I have enabled multi-write enabled for the Cosmos account in azure portal. I don't understand if it is mandatory to set the ApplicationRegion...
Read more >
PatchItem method in sample code which should not be ...
In sample code of below doc there is one line ".PatchItem(test4.id, patchOperations)" but we actually don't GA partial update now right?
Read more >
How multiple writes and reads are handled in Azure ...
This article presents how to enable geo-replication and multiple writes regions in the Azure Cosmos DB.
Read more >
Availability and best practices for the Azure Cosmos DB .NET ...
In this episode, Mark sits down with Matias Quaranta. We'll do a deep dive into the SDK on connectivity, understand how each connection...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found