Description
The problem exists in: https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.16.0 (the latest version of v3 client) and does not exist in https://www.nuget.org/packages/Azure.Cosmos/4.0.0-preview3 (latest v4 preview client)
Describe the bug
A cosmosdb instance was created in SouthEastAsia region with "Session" default consistency. The following C# code was used to create a DB if not exist:
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions
{
ConsistencyLevel = ConsistencyLevel.ConsistentPrefix
};
CosmosClient cosmosClient = new CosmosClient(CosmosEndpointUrl, AuthKey, cosmosClientOptions);
DatabaseResponse databaseResponse = await cosmosClient.CreateDatabaseIfNotExistsAsync(DatabaseId);
This throws a System.ArgumentException
saying "Consistency level Bounded Staleness specified in the request is invalid when service is configured with consistency level Session"
. This error it self is wrong as Bounded Staleness was not mentioned in the code. If ConsistencyLevel = ConsistencyLevel.Eventual
is used in the cosmosClientOptions
there error does not appear.
To Reproduce
- Create a cosmos db instance with
Session
default consistency level - Try to create a database in the cosmosdb instance via a code similar to the above - an exception will be thrown.
Expected behavior
There should not be any error if the cosmos client if instantiated with a weaker consistency than the default constituency defined in the cosmosdb instance.
Actual behavior
A misleading exception is being thrown.
Environment summary
SDK Version: Microsoft.Azure.Cosmos 3.16.0
Framework: .NET Core 3.1
OS Version: Windows 10 20H2 19042.746
Additional context
https://pbs.twimg.com/media/EtmPEIJU0AMtqvA?format=png&name=large