Azure Cosmos DB – Consistency, Partitioning and SDK · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage
A .NET application uses the Azure Cosmos DB SDK v3. The container's partition key path is /customerId, and the application must retrieve the item wit…
Practice question from Azure Cosmos DB – Consistency, Partitioning and SDK (AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage), with the correct answer and a step-by-step solution.
hard · MCQ · Q-D045B1
A .NET application uses the Azure Cosmos DB SDK v3. The container's partition key path is /customerId, and the application must retrieve the item with id order-42 for customer contoso using a point read. Which statement correctly performs the operation?
- A.await container.ReadItemAsync<Order>("order-42", new PartitionKey("contoso"));Correct answer
- B.await container.ReadItemAsync<Order>(new PartitionKey("contoso"), "order-42");
- C.await container.ReadItemAsync<Order>("order-42");
- D.await container.GetItemQueryIterator<Order>("SELECT * FROM c WHERE c.id = 'order-42'").ReadNextAsync();
Solution
The SDK v3 point-read signature is ReadItemAsync<T>(id, partitionKey). Supplying both the item ID and its partition-key value targets the specific logical partition efficiently. Option D performs a query rather than a point read, and the other options use an invalid or incomplete signature.
More from Azure Cosmos DB – Consistency, Partitioning and SDK
- An application uses Azure Cosmos DB to update a user's profile and then immediately read the profile during the same user session. The read…
- A Cosmos DB container stores telemetry for many tenants. Its current partition key is /tenantId, but one tenant produces most of the teleme…
- A globally distributed Azure Cosmos DB account must allow reads from any region, but each read may lag behind the latest write by no more t…
- An Azure Cosmos DB container stores orders for 10,000 retail stores. Most queries retrieve orders for a specific store, and writes are dist…
Practise more Develop for Azure Storage
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed