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)
- 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.Cevap
- Explicitly pass the `TenantId` value as a `PartitionKey` parameter in the SDK item operation methods such as `CreateItemAsync` or `ReadItemAsync`.Cevap
- CRely on the account-level Session consistency configuration to automatically guarantee read-your-writes consistency across the separate client instances without manually sharing session tokens.
- DChange the container's partition key to a low-cardinality field like `/Country` or `/TenantStatus` to optimize physical partition distribution.
Cevap
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.
Adım Adım Çözüm
Anahtar Kavram
Managing session consistency tokens across multiple client instances and passing partition keys in SDK operations.
Tahmini Süre:1m 30s