Question

Difficulty: MediumPerform Container and Item Operations in Azure Cosmos DB using SDK

A multi-tenant SaaS application stores tenant-specific documents in a single Azure Cosmos DB container using the .NET SDK v3. The container is configured with a partition key path of `/TenantId`, and the database account uses the default Session consistency level. Separate instances of the client application run on different virtual machines, each initializing its own `CosmosClient` instance.

You need to ensure that reads and writes performed by separate client instances achieve read-your-writes consistency while maintaining optimal write/read partition distribution and meeting SDK design standards.

Which of the following actions should you perform to implement this correctly? (Select TWO)

  1. Retrieve the session token from the write response headers on one client instance and pass it in the request options of subsequent read requests on other client instances.Answer
  2. Explicitly pass the `TenantId` value as a `PartitionKey` parameter in the SDK item operation methods such as `CreateItemAsync` or `ReadItemAsync`.Answer
  3. C
    Rely on the account-level Session consistency configuration to automatically guarantee read-your-writes consistency across the separate client instances without manually sharing session tokens.
  4. D
    Change the container's partition key to a low-cardinality field like `/Country` or `/TenantStatus` to optimize physical partition distribution.

Answer

To configure the Cosmos DB SDK operations correctly, you must pass the session token between separate client instances to maintain session consistency, and you must explicitly pass the partition key in all item operation calls.
To maintain read-your-writes consistency across separate CosmosClient instances, you must manually pass the session token from the write response to the subsequent read requests. Additionally, when using the .NET SDK v3, performing item operations requires explicitly passing the PartitionKey parameter to target the correct logical partition and avoid exceptions.

Step-by-Step Solution

1
Analyze consistency scope across multiple client instances.
Determine that Session consistency is scoped to the client instance, meaning different instances require explicit token sharing.
Ensures read-your-writes guarantees are met globally across instances.
2
Analyze SDK requirement for item operations.
Identify that the Cosmos DB .NET SDK v3 requires passing the partition key value as a parameter in item-level methods.
Ensures operations target the correct logical partition and prevents SDK runtime validation errors.

Key Concept

Managing session consistency tokens across multiple client instances and passing partition keys in SDK operations.
Estimated Time:1m 30s
Rate this question