Skip to main content

Last updated: May 2026

Practice Exam

DP-420Azure Cosmos DB Developer Specialty

Test your knowledge with official exam-style questions

Questions25Passing700Exam time120 min

Questions and options are shuffled each attempt

Microsoft Certified: Azure Cosmos DB Developer SpecialtyPractice Set 1: All Questions & Explanations

Full question text, answer options, and explanations for this practice set — a spoiler-free alternative is the interactive quiz above for scored, shuffled practice.

  1. 1. A developer is designing an Azure Cosmos DB for NoSQL data model for an e-commerce application. Orders and their line items are always retrieved together and line items are never queried independently. Which design approach best optimizes read performance?

    • A. Store Orders and LineItems in separate containers with a foreign key reference
    • B. Store LineItems as an array embedded within the parent Order document(correct)
    • C. Create a relational join between Orders and LineItems using a stored procedure
    • D. Store LineItems in a separate container and use Change Feed to synchronize them

    Explanation: When related entities are always read together and child entities are not queried independently, embedding them in the parent document eliminates cross-document reads and reduces RU consumption per request. Separate containers (A, D) would require cross-partition queries or application-side joins. Stored procedures (C) with relational joins are not a pattern in Cosmos DB for NoSQL.

  2. 2. A Cosmos DB container must automatically delete session documents 30 minutes after they are created. Which feature should the developer configure?

    • A. A stored procedure that deletes documents older than 30 minutes on a timer
    • B. An Azure Function triggered by Change Feed to delete old documents
    • C. A default Time to Live (TTL) of 1800 seconds set on the container(correct)
    • D. A Cosmos DB Trigger that fires on document creation and schedules deletion

    Explanation: Setting a default TTL on the container to 1800 seconds (30 minutes) causes Cosmos DB to automatically delete documents after that duration with no application code required. A stored procedure timer (A) and a Change Feed Function (B) are unnecessarily complex and incur additional RU cost. Cosmos DB does not have a built-in trigger type that schedules future deletion (D).

  3. 3. A product catalog application stores products across 12 distinct categories. Each category has between 500 and 50,000 products, and product reads are almost always filtered by category. The team wants to minimize cross-partition queries. Which partition key should the developer choose?

    • A. productId, because it provides maximum uniqueness
    • B. category, because it aligns with the primary query pattern and keeps related data together(correct)
    • C. createdDate, because it distributes documents chronologically
    • D. A synthetic key combining category and productId to avoid hot partitions

    Explanation: The partition key should align with the most common query predicate so that most queries are single-partition. Since reads are always filtered by category, using category as the partition key maximizes in-partition query efficiency. Using productId (A) would scatter products across many partitions, forcing cross-partition scans for category queries. createdDate (C) creates hot partitions for recent writes and is not aligned with read patterns. A synthetic key (D) adds complexity and does not improve in-partition access for category-level queries.

  4. 4. A developer uses the Azure Cosmos DB .NET SDK to perform a point read of an item by its id and partition key. The application later performs a query using a SQL WHERE clause. Which statement correctly describes when to prefer a point operation?

    • A. Point reads should be used when retrieving multiple items from different partitions
    • B. Point reads should be used when both the item id and partition key value are known, as they consume 1 RU and have predictable sub-10ms latency(correct)
    • C. Point reads are most efficient when filtering on a non-partition-key property
    • D. Point reads should be preferred over queries only when the container has no index

    Explanation: A point read (ReadItemAsync) uses the id and partition key to retrieve a single item directly at a cost of approximately 1 RU, regardless of document size, and with single-digit millisecond latency. A query using WHERE must traverse the index and incurs higher RU cost. Point reads require knowing both the id and partition key; they are not suitable for filtering on non-partition-key properties (C) or multi-item retrieval across partitions (A). The index (D) is irrelevant to the point read vs. query choice.

  5. 5. A developer needs to implement a multi-item bank transfer that debits one account and credits another within the same logical partition in Azure Cosmos DB for NoSQL. Which TWO SDK features should the developer use to ensure atomicity? Choose 2.

    • A. SDK Transactional Batch to group both operations into a single atomic request(correct)
    • B. A stored procedure that executes both read and write operations within the same logical partition(correct)
    • C. Two separate UpsertItemAsync calls executed back-to-back in application code
    • D. Azure Event Hubs to coordinate the debit and credit as distributed events
    • E. Optimistic concurrency control using ETags to retry on conflict

    Explanation: Both SDK Transactional Batch and stored procedures guarantee all-or-nothing atomicity for multiple operations within the same logical partition. The Transactional Batch groups operations into a single atomic request on the client side; a stored procedure encapsulates the logic server-side. Two separate SDK calls (C) are not atomic — a failure between them leaves data inconsistent. Azure Event Hubs (D) is an event streaming service and provides no ACID guarantees. ETags (E) provide optimistic concurrency on a single item, not multi-item atomicity.

  6. 6. A team migrates an existing workload to Azure Cosmos DB and needs to construct a synthetic partition key. The source data has two candidate fields: tenantId (low cardinality, ~10 values) and deviceId (high cardinality, millions of values). What is the correct approach for constructing the synthetic key?

    • A. Use only tenantId because it keeps all tenant data in the same partition for efficient queries
    • B. Use only deviceId because it provides the highest cardinality and best distribution
    • C. Concatenate tenantId and deviceId to create a composite value that achieves both query efficiency and high cardinality(correct)
    • D. Hash the createdDate to create a random partition key

    Explanation: A synthetic partition key combining tenantId and deviceId achieves high cardinality (preventing hot partitions) while still allowing efficient single-partition queries when both values are known. Using only tenantId (A) creates hot partitions for tenants with many devices. Using only deviceId (B) maximizes distribution but requires cross-partition fan-out for tenant-level queries. Hashing createdDate (D) distributes writes randomly but makes all queries cross-partition.

  7. 7. A developer implements a stored procedure in Azure Cosmos DB for NoSQL that processes a batch of 500 items. During testing, the stored procedure times out before processing all items. What is the correct pattern for handling this situation in a stored procedure?

    • A. Increase the container's provisioned RUs to 100,000 to ensure the stored procedure completes
    • B. Split the stored procedure into multiple stored procedures and call them in sequence from the client
    • C. Implement a continuation pattern: check getContext().getResponse().getResourceQuotaUsage() and return a continuation token when time is low, then re-invoke the stored procedure from the client(correct)
    • D. Use Bulk Support in the SDK instead, which automatically partitions large batches

    Explanation: Stored procedures in Cosmos DB are bounded execution — they must complete within a fixed time limit. The recommended pattern is to check the remaining execution time or response quota inside the procedure loop, save state as a continuation token, and return it to the client to re-invoke the procedure where it left off. Increasing RUs (A) does not extend the time limit. Multiple separate stored procedures (B) are not atomic across invocations. Bulk Support (D) is a good alternative but does not make stored procedures work correctly — the question is specifically about fixing the stored procedure pattern.

  8. 8. An Azure Cosmos DB for NoSQL application needs to implement optimistic concurrency to prevent lost updates when two clients read and modify the same document concurrently. Which SDK feature should the developer use?

    • A. A Cosmos DB trigger that locks the document during updates
    • B. ETags with the IfMatchEtag condition in the request options(correct)
    • C. A stored procedure with pessimistic locking
    • D. Session consistency to ensure reads see the latest committed version

    Explanation: Cosmos DB implements optimistic concurrency using ETags. Each document has a system-assigned _etag property. By setting IfMatchEtag in the request options on a replace or delete operation, Cosmos DB will reject the operation with a 412 Precondition Failed if the document was modified since it was last read. Cosmos DB does not support pessimistic locking (A, C). Session consistency (D) ensures read-your-own-writes but does not prevent concurrent update conflicts.

  9. 9. A developer needs to choose between serverless and provisioned throughput for a new Cosmos DB container that supports a development workload with sporadic, unpredictable traffic and very low sustained RU/s consumption. Which option is most cost-effective?

    • A. Provisioned throughput at 400 RU/s, because it provides the lowest dedicated baseline
    • B. Autoscale provisioned throughput with a 1000 RU/s maximum
    • C. Serverless, because it charges only for the RUs actually consumed and has no minimum charge(correct)
    • D. Free tier, because it provides 1000 RU/s and 25 GB free per account

    Explanation: Serverless Cosmos DB charges only for the RUs actually consumed per request with no hourly minimum. For dev/test workloads with sporadic, low-volume traffic, this is the most cost-effective option. Provisioned throughput at 400 RU/s (A) charges continuously even when idle. Autoscale (B) has a higher minimum cost than serverless for very low utilization. Free tier (D) is limited to one per Azure account and is not applicable if the account already uses it for production.

  10. 10. An Azure Cosmos DB account is configured for multi-region writes in East US and West Europe. A write conflict occurs when two clients in different regions simultaneously update the same document. Which conflict resolution policy should the developer implement to use a custom server-side merge function?

    • A. Last Write Wins (LWW), using the default _ts timestamp property
    • B. Last Write Wins with a custom numeric property as the conflict resolution path
    • C. Custom conflict resolution policy using a stored procedure registered as the conflict resolver(correct)
    • D. Manual conflict resolution by reading the conflict feed and resolving in the application

    Explanation: Cosmos DB supports a Custom conflict resolution policy where a stored procedure is registered as the merge handler. The stored procedure receives conflicting versions and can implement domain-specific logic to produce the final winning document. LWW (A, B) uses a numeric property's maximum value as the tiebreaker — it does not allow custom merge logic. Manual conflict resolution via the conflict feed (D) defers resolution to the application asynchronously and is not a server-side automatic approach.

  11. 11. A global application requires strongly consistent reads for its financial module. The Cosmos DB account has four read regions. The developer enables Strong consistency. What is the expected impact on read latency and availability compared to using Session consistency?

    • A. Strong consistency has lower latency because it reads from the nearest region
    • B. Strong consistency has higher latency because reads must synchronously replicate across all write regions and wait for a quorum before returning(correct)
    • C. Strong consistency has the same latency as Session consistency but provides stronger guarantees
    • D. Strong consistency is unavailable during regional failures and has the same latency as Bounded Staleness

    Explanation: Strong consistency in Cosmos DB requires that reads observe the latest committed write, which means every read must contact the primary write region (or wait for quorum acknowledgement across regions). This increases read latency, especially for clients geographically far from the write region. Session consistency (C) allows reads from the nearest replica after the client's own writes are visible, giving much lower latency. Strong consistency does limit availability under regional partitions (D) but is not identical to Bounded Staleness latency-wise.

  12. 12. A developer needs to trigger an Azure Function every time a document is inserted or updated in a Cosmos DB container to fan out notifications. Which integration pattern should they implement?

    • A. Schedule the Azure Function to poll the container every minute using a Timer trigger
    • B. Use an Azure Cosmos DB trigger for Azure Functions backed by the Change Feed(correct)
    • C. Configure an Azure Logic App to check for new documents every hour
    • D. Use Azure Event Grid with a custom topic to emit Cosmos DB events

    Explanation: The Azure Cosmos DB trigger for Azure Functions is powered by the Change Feed and is the recommended, event-driven pattern. It invokes the Function automatically when documents are created or updated, with at-least-once delivery and ordered delivery within a partition key. Polling with a Timer trigger (A) introduces latency and wastes RUs. Logic Apps polling (C) is hourly and not near-real-time. Event Grid (D) can be used for control-plane events but not for per-document data changes.

  13. 13. A data engineering team wants to run complex analytical queries over the Cosmos DB transactional store without impacting the production OLTP workload. They prefer to use Azure Synapse Analytics SQL serverless pools. Which feature should they enable?

    • A. Azure Cosmos DB Mirroring for Microsoft Fabric
    • B. Azure Cosmos DB Analytical Store with a Synapse Link connection(correct)
    • C. Export data to Azure Blob Storage nightly using Azure Data Factory and query from Synapse
    • D. Point-in-time restore to a separate account for analytical queries

    Explanation: Azure Synapse Link enables the Cosmos DB Analytical Store — a column-oriented, auto-synced copy of the transactional data that allows Azure Synapse SQL serverless pools or Spark pools to query historical and current data without impacting OLTP performance. Mirroring for Fabric (A) targets Microsoft Fabric Lakehouse, not Synapse SQL serverless. Nightly ADF exports (C) introduce latency and operational overhead. Point-in-time restore (D) is for disaster recovery, not analytics.

  14. 14. An application executes a Cosmos DB query that returns 10,000 documents and the team observes that it consumes 5,000 RUs per execution. The query does not use the partition key in the WHERE clause and includes an ORDER BY on a non-indexed property. Which two changes would most reduce RU consumption?

    • A. Add the partition key value to the WHERE clause to make it a single-partition query(correct)
    • B. Add a composite index on the ORDER BY property and the partition key
    • C. Increase the container's throughput to 50,000 RU/s
    • D. Enable the Cosmos DB integrated cache to serve repeated queries from memory

    Explanation: Cross-partition queries fan out to all physical partitions and multiply RU cost by the number of partitions. Adding the partition key to the WHERE clause converts the cross-partition query to a single-partition query, drastically reducing RU cost. Adding a composite index (B) helps ORDER BY performance within a partition but does not eliminate cross-partition fan-out. Increasing throughput (C) raises capacity limits but does not reduce the RUs consumed per query. The integrated cache (D) reduces cost for repeated identical queries but does not fix the underlying query inefficiency.

  15. 15. A developer needs to exclude a large binary property (thumbnailData) from the Cosmos DB index to reduce index storage and write RU costs. The property is never used in query predicates. How should the developer configure the indexing policy?

    • A. Set indexingMode to 'none' to disable indexing entirely on the container
    • B. Add /thumbnailData/* to the excludedPaths array in the container's indexing policy(correct)
    • C. Remove the thumbnailData property from the document before writing to Cosmos DB
    • D. Use a stored procedure to write the document, bypassing the indexer

    Explanation: Cosmos DB indexing policies support fine-grained path-level exclusions. Adding /thumbnailData/* to excludedPaths tells the indexer to skip this property, reducing index size and write RU cost while leaving all other properties indexed and queryable. Disabling indexing entirely (A) would make all queries perform full scans. Removing the property from the document (C) changes the data schema and loses the stored data. Stored procedures do not bypass the indexer (D).

  16. 16. A developer implements a Change Feed processor in a .NET application. After several hours, the processor falls significantly behind the live write stream. The team wants to know whether to add more processor instances. Which API should the developer use to measure the Change Feed lag?

    • A. Azure Monitor metrics — Normalized RU Consumption
    • B. The Change Feed estimator in the Cosmos DB SDK(correct)
    • C. Azure Monitor alert on Server Side Latency
    • D. The partition key statistics endpoint in the REST API

    Explanation: The Change Feed estimator is a built-in SDK API that reports the estimated number of remaining changes (the lag) between the current processor position and the tip of the change feed, per partition. This directly answers whether the processor is falling behind and whether additional processor instances are needed. Normalized RU Consumption (A) measures throughput utilization, not change feed lag. Server Side Latency (C) measures request latency. Partition key statistics (D) report data distribution, not feed processing lag.

  17. 17. A read-heavy Cosmos DB workload executes the same parameterized product query thousands of times per minute. The query results change only every few minutes. A developer wants to reduce RU consumption on repeated identical queries. Which feature is most appropriate?

    • A. Add a composite index on the query's ORDER BY and WHERE properties
    • B. Enable the Azure Cosmos DB integrated cache on the dedicated gateway(correct)
    • C. Enable multi-region reads to distribute query load across replicas
    • D. Use Autoscale throughput so the container can burst during peak load

    Explanation: The Azure Cosmos DB integrated cache is a server-side, in-memory cache on the dedicated gateway tier that caches item reads and query results. Repeated identical queries that hit the cache return results at 0 RU cost, which significantly reduces both RU consumption and latency for high-frequency repeated queries. A composite index (A) reduces per-query cost but does not cache results — identical repeated queries still consume RUs each time. Multi-region reads (C) distribute load but each replica still executes the query. Autoscale (D) increases capacity but does not reduce the RUs consumed per query.

  18. 18. A Cosmos DB application is receiving HTTP 429 responses from the service. What does this status code indicate and what is the recommended SDK-level handling?

    • A. 429 indicates an authentication failure; the developer should refresh the connection string
    • B. 429 indicates the request was rate-limited (Too Many Requests); the SDK should retry after the RetryAfter interval provided in the response(correct)
    • C. 429 indicates a network timeout; the developer should switch to Gateway connectivity mode
    • D. 429 indicates a partition split; the SDK automatically retries after the split completes

    Explanation: HTTP 429 (Too Many Requests) in Cosmos DB means the application has exceeded the provisioned RU/s for the container or database. The response includes a Retry-After-Ms header indicating how long to wait before retrying. The Cosmos DB SDK has built-in retry logic that honors this interval. 429 is not an authentication error (A), a network timeout (C), or a partition split indicator (D) — partition splits return no error; they are transparent to the client.

  19. 19. An operations team needs to detect when a Cosmos DB container's provisioned throughput is consistently over-utilized, as indicated by the Normalized RU Consumption metric exceeding 80% for more than 5 minutes. Which Azure Monitor capability should they configure?

    • A. A Log Analytics query run on demand to check historical metrics
    • B. An Azure Monitor metric alert rule on the Normalized RU Consumption metric with a threshold of 80%(correct)
    • C. A Cosmos DB diagnostic setting that emits PartitionKeyStatistics to a storage account
    • D. An Azure Advisor recommendation for cost optimization

    Explanation: Azure Monitor metric alert rules allow teams to configure proactive notification when a metric breaches a threshold for a specified evaluation window. Configuring an alert on Normalized RU Consumption > 80% for 5 minutes triggers an action group (email, webhook, etc.) automatically. Log Analytics queries (A) are reactive and manual. Diagnostic settings for PartitionKeyStatistics (C) measure data distribution, not throughput saturation. Azure Advisor (D) provides periodic recommendations but not real-time alerts.

  20. 20. A team needs to implement data-plane security for an Azure Cosmos DB account. They want to avoid using primary/secondary account keys and instead use identity-based access. Which TWO approaches achieve this? Choose 2.

    • A. Manage data plane access using Microsoft Entra ID with Cosmos DB built-in RBAC roles(correct)
    • B. Store the primary account key in Azure Key Vault and retrieve it at runtime
    • C. Assign a managed identity to the application and grant it Cosmos DB data reader/contributor role via Azure RBAC(correct)
    • D. Use IP firewall rules to restrict access to trusted IP ranges
    • E. Enable public network access and use CORS to restrict origins

    Explanation: Microsoft Entra ID–based data plane access uses Cosmos DB built-in RBAC roles (e.g., Cosmos DB Built-in Data Contributor) assigned to users, service principals, or managed identities — eliminating the need for account keys entirely. Storing the key in Key Vault (B) still uses account keys and doesn't eliminate them. IP firewall rules (D) control network-level access but still require key or Entra ID credentials for authentication. CORS (E) restricts browser origins for web clients but is not an authentication mechanism.

  21. 21. A production Cosmos DB container was accidentally dropped by a developer 4 hours ago. The account was configured with continuous backup (7-day retention). The team needs to recover the container with minimal data loss. What is the correct recovery approach?

    • A. Restore the entire account to a new account at a point in time 5 hours ago using the Azure portal or CLI(correct)
    • B. Run a manual failover to the secondary region, which retains the deleted container
    • C. Recover the container from the most recent periodic backup
    • D. Recreate the container schema manually and reload data from the Change Feed

    Explanation: Continuous backup with point-in-time restore allows restoring to any point within the retention window. Restoring to 5 hours ago (1 hour before the deletion) recovers the container with minimal data loss. The restore targets a new account to avoid overwriting existing data. A regional failover (B) does not recover deleted containers — deletion is replicated to all regions. Periodic backup (C) is a separate mode not applicable when continuous backup is configured. Reloading from Change Feed (D) does not work for deleted containers as the feed also records the deletion.

  22. 22. A developer needs to move 50 million documents from an on-premises MongoDB database to Azure Cosmos DB for NoSQL. The migration must be completed within a weekend and the source system remains online during migration. Which tool is best suited for this bulk data movement?

    • A. SDK Bulk Support (BulkExecutor) writing directly from a custom migration app
    • B. Azure Data Factory with a Cosmos DB sink using the Copy activity(correct)
    • C. Azure Stream Analytics reading from the MongoDB change stream
    • D. Azure Cosmos DB Spark connector with a Databricks cluster

    Explanation: Azure Data Factory's Copy activity with Cosmos DB as a sink supports large-scale bulk migrations from heterogeneous sources (including MongoDB) with configurable parallelism and throughput controls. It is the recommended managed service for scheduled, time-bounded migrations. SDK Bulk Support (A) requires writing and maintaining custom code and managing parallelism manually. Azure Stream Analytics (C) processes streaming data, not bulk historical migration. The Spark connector (D) requires an active Databricks cluster and is better suited for continuous or analytical workloads.

  23. 23. A DevOps engineer needs to provision an Azure Cosmos DB account, database, and container as infrastructure-as-code so that the same configuration can be deployed consistently across dev, test, and production environments. Which approach should they use?

    • A. Use the Azure portal to manually create each environment and document the settings
    • B. Provision and manage Cosmos DB resources using Azure Resource Manager (ARM) templates or Bicep(correct)
    • C. Write a PowerShell script that uses the Cosmos DB REST API to create resources imperatively
    • D. Use the Cosmos DB SDK to create the account programmatically from the application startup code

    Explanation: ARM templates and Bicep are declarative infrastructure-as-code tools that describe the desired state of Cosmos DB resources and support repeatable deployments across environments via CI/CD pipelines. The Azure portal (A) is manual and error-prone across multiple environments. A PowerShell script using the REST API (C) is imperative, harder to diff and review, and less idempotent. Creating resources from application startup code (D) mixes infrastructure provisioning with application logic and is not suitable for production governance.

  24. 24. A security audit requires that an Azure Cosmos DB account implement encryption with customer-managed keys (CMK) using Azure Key Vault. Which TWO requirements must be met when configuring CMK for Cosmos DB? Choose 2.

    • A. The Key Vault must have soft-delete and purge protection enabled(correct)
    • B. The Cosmos DB account's managed identity must be granted Get, Wrap Key, and Unwrap Key permissions on the Key Vault key(correct)
    • C. CMK can be enabled on an existing container at any time without recreating the account
    • D. The Key Vault must be in the same Azure region as the Cosmos DB account
    • E. CMK must be configured at account creation time and cannot be added post-creation to an existing account

    Explanation: For CMK with Cosmos DB, the Key Vault must have soft-delete and purge protection enabled to prevent accidental or malicious deletion of the encryption key, which would render the database permanently inaccessible. Additionally, the Cosmos DB account's system-assigned or user-assigned managed identity must be granted the specific Key Vault access policy permissions: Get, Wrap Key, and Unwrap Key. The Key Vault does not need to be in the same region (D). CMK can be added to existing accounts (E is false — Microsoft supports enabling CMK on existing accounts in some scenarios). Answer C is false as CMK is account-level, not container-level.

  25. 25. A team monitors a Cosmos DB container and notices uneven data distribution — one partition key value (customerId='enterprise-1') holds 80% of all data. Which TWO actions should the developer take to address this hot partition problem? Choose 2.

    • A. Redesign the partition key to use a higher-cardinality property or synthetic key that distributes data more evenly(correct)
    • B. Implement a hierarchical partition key using customerId as the first level and a sub-partition property (e.g., orderId) as the second level(correct)
    • C. Increase the container's provisioned RUs to compensate for the hot partition
    • D. Enable geo-replication to distribute the hot partition data across regions
    • E. Add a TTL to expire old documents in the hot partition

    Explanation: A hot partition caused by low-cardinality or skewed data requires a partitioning redesign. Choosing a higher-cardinality or synthetic partition key (A) distributes data evenly across partitions. Hierarchical partition keys (B) allow a two-level partition scheme where the first level (customerId) can be combined with a second level (e.g., orderId) to distribute sub-items within a logical tenant, preventing single-partition saturation. Increasing RUs (C) raises the global throughput limit but does not solve the per-partition 10,000 RU/s cap. Geo-replication (D) copies all data to more regions but does not redistribute data within a region's partitions. TTL (E) reduces data volume over time but does not fix the structural distribution problem.