Azure Cosmos DB – Consistency, Partitioning and SDK · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage

A Cosmos DB container stores telemetry for many tenants. Its current partition key is /tenantId, but one tenant produces most of the telemetry, causi…

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.

medium · MCQ · Q-40BF91

A Cosmos DB container stores telemetry for many tenants. Its current partition key is /tenantId, but one tenant produces most of the telemetry, causing a hot logical partition and uneven request distribution. Queries commonly filter by tenant and time, and transactions do not need to span multiple devices. Which redesign is most appropriate?

  1. A.Keep /tenantId because all queries include the tenant identifier.
  2. B.Use /timestamp so recent telemetry is always placed together.
  3. C.Use a high-cardinality synthetic key such as tenantId + ':' + deviceId.Correct answer
  4. D.Use the tenant's display name and manually move items between partitions.

Solution

A high-cardinality synthetic key such as tenantId + ':' + deviceId distributes writes for a large tenant across multiple logical partitions while retaining tenant information for filtering. A partition key is selected when the container is created; changing it generally requires creating a new container and migrating the data.

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