An IoT application ingests telemetry data and writes it to an Azure Cosmos DB container configured with a partition key of /DeviceId. Which two of the following statements about performing item operations using the Cosmos DB .NET SDK v3 are correct? (Select TWO).
- To create a new item, you should call CreateItemAsync<T>(item, new PartitionKey(item.DeviceId)) on the Container instance, passing both the item details and the partition key.Cevap
- To retrieve a single item efficiently (a point read), you should call ReadItemAsync<T>(id, new PartitionKey(deviceId)) on the Container instance to avoid a cross-partition query.Cevap
- CTo achieve read-your-writes guarantees (Session consistency) across multiple independent client sessions, you only need to set the consistency level to Session on the CosmosClient without sharing the Session Token.
- DTo optimize ingestion rates, you should select a low-cardinality property (like 'Status') as the partition key and omit the PartitionKey parameter in CreateItemAsync.
Cevap
The correct statements are that creating a new item requires calling CreateItemAsync with the item and a PartitionKey, and retrieving a single item efficiently (point read) requires calling ReadItemAsync with the id and PartitionKey.
The .NET SDK v3 Container class provides methods like CreateItemAsync and ReadItemAsync to perform item-level operations. These operations require the item's partition key to be explicitly passed as a parameter (e.g., using new PartitionKey(value)) to ensure they are directed to the correct physical partition, avoiding performance issues or cross-partition queries.
Adım Adım Çözüm
Anahtar Kavram
Performing item operations using the Cosmos DB .NET SDK v3
Tahmini Süre:1m 30s