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?

  1. A.await container.ReadItemAsync<Order>("order-42", new PartitionKey("contoso"));Correct answer
  2. B.await container.ReadItemAsync<Order>(new PartitionKey("contoso"), "order-42");
  3. C.await container.ReadItemAsync<Order>("order-42");
  4. 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

All of Azure Cosmos DB – Consistency, Partitioning and SDK

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 free

Free to start · No credit card needed