DP-420 sample exam questions
15 exam-style questions for Microsoft DP-420: Azure Cosmos DB Developer, with answers and explanations. Take them as a timed practice exam first if you want a score out of 1000.
- You need to implement a trigger in Azure Cosmos DB Core (SQL) API that will run before an item is inserted into a container.
Which two actions should you perform to ensure that the trigger runs? Each correct answer presents part of the solution.
NOTE: Each correct selection is worth one point.- AAppend pre to the name of the JavaScript function trigger.
- BFor each create request, set the access condition in RequestOptions.
- CRegister the trigger as a pre-trigger.
- DFor each create request, set the consistency level to session in RequestOptions.
- EFor each create request, set the trigger name in RequestOptions.
Show answer
Correct answer: C, E
WhyThe community answer lists only C, but two actions are required. A trigger must be registered as a pre-trigger, and Cosmos DB triggers never run automatically, so each create request must name the trigger in RequestOptions (PreTriggers). Function naming, access conditions and session consistency do not invoke triggers.
- A
- HOTSPOT
You have an Azure Cosmos DB container named container1.
You need to insert an item into container1. The solution must ensure that the item is deleted automatically after two hours.
How should you complete the item definition? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

Property name defaultTimeToLive / ttl / _ttl Property value -1 / 2 / 120 / 7200 Show answer
- Property name ttl
- Property value 7200
WhyAn item sets its own expiry with the ttl property, in seconds, so two hours is 7200. defaultTimeToLive is a container setting, and the container must have TTL enabled for an item's ttl to take effect.
- You plan to create an Azure Cosmos DB account that will use the NoSQL API.
You need to create a grouping strategy for items that will be stored in the account. The solution must ensure that write and read operations on the items can be performed within the same transaction.
What should you use to group the items?- Alogical partitions
- Bphysical partitions
- Cdatabases
- Dcontainers
Show answer
Correct answer: A
WhyTransactions in Cosmos DB, such as stored procedures and transactional batch, are scoped to a single logical partition, so items grouped in the same logical partition can be read and written in one transaction. Physical partitions are managed by the service; containers and databases span partitions.
- A
- HOTSPOT
You have an Azure Cosmos DB for NoSQL account named account1 in a resource group named RG1. The Azure regions for account1 are shown in the following table.

You need to fail over account1 from the East US region to the Central US region by using Azure Command-Line Interface (CLI).
How should you complete the command? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

az cosmosdb failover-priority-change / locations / network-rule / update Parameter before "centralus=0" "westus=1" "eastus=2" --enable-automatic-failover / --failover-policies / failoverPriority=0 Show answer
- az cosmosdb failover-priority-change
- Parameter before "centralus=0" "westus=1" "eastus=2" --failover-policies
Whyaz cosmosdb failover-priority-change sets the region order, and --failover-policies lists each region with its priority. Priority 0 is the write region, so centralus=0 moves writes from East US to Central US.
- HOTSPOT
You have an Azure subscription that contains an Azure Cosmos DB for NoSQL account.
You define and implement an encryption policy by using the following C# code:

For each of the following statements, select Yes if the statement is true, otherwise select No.
NOTE: Each correct selection is worth one point.

Queries can retrieve items from the Customers container by using the taxId field. Yes / No If two customers have the same credit card value, the encrypted fields will contain the same value. Yes / No The Customers container is created if the container does NOT exist. If the container exists, the policy of the container is updated. Yes / No Show answer
- Queries can retrieve items from the Customers container by using the taxId field. Yes
- If two customers have the same credit card value, the encrypted fields will contain the same value. No
- The Customers container is created if the container does NOT exist. If the container exists, the policy of the container is updated. No
WhyDeterministic encryption on taxId produces the same ciphertext for the same value, so equality queries work. Randomized encryption on creditCard produces different ciphertext each time. CreateAsync only creates a container and fails with a conflict if it already exists; it never updates the policy.
- You have a database named db1 in an Azure Cosmos DB Core (SQL) API account.
You have a third-party application that is exposed through a REST API.
You need to migrate data from the application to a container in db1 on a weekly basis.
What should you use?- AAzure Migrate
- BAzure Data Factory
- CDatabase Migration Assistant
Show answer
Correct answer: B
WhyAzure Data Factory has a REST connector as a source and a Cosmos DB for NoSQL sink, and can run on a weekly schedule trigger. Azure Migrate and Database Migration Assistant target server or SQL database migrations, not REST-to-Cosmos DB data copies.
- A
- Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have a container named container1 in an Azure Cosmos DB for NoSQL account.
You need to make the contents of container1 available as reference data for an Azure Stream Analytics job.
Solution: You create an Azure Synapse pipeline that uses Azure Cosmos DB for NoSQL change feed as a trigger and an Azure event hub as the output.
Does this meet the goal?- AYes
- BNo
Show answer
Correct answer: B
WhyNo. The change feed trigger with Event Hubs output creates a stream, but Event Hubs cannot be a Stream Analytics reference data input. Reference data requires Blob Storage or SQL Database, so the data would need to be written to one of those.
- A
- You have an Azure subscription.
You plan to create an Azure Cosmos DB for NoSQL database named DB1 that will store author and book data for authors that have each published up to ten books. Typical and frequent queries of the data will include:
• All books written by an individual author
• The synopsis of individual books
You need to recommend a data model for DB1. The solution must meet the following requirements:
• Support transactional updates of the author and book data.
• Minimize read operation costs.
What should you recommend?- ACreate a single container that stores author items and book items, and then items that represent the relationship between the authors and their books.
- BCreate three containers, one that stores author items, a second that stores book items, and a third that stores items that represent the relationship between the authors and their books.
- CCreate two containers, one that stores author items and another that stores book items. Embed a list of each author’s books in the corresponding author item.
- DCreate a single container that stores author items and book items. Embed a list of each author’s books in the corresponding author item.
Show answer
Correct answer: D
WhyEmbedding the up-to-ten books in each author item inside one container lets a single point read return an author with all books, which minimizes RU cost. Writes to one item are transactional. Separate containers or relationship items need cross-container reads and cannot be updated transactionally.
- A
- HOTSPOT
You have an Azure Cosmos DB for NoSQL account that contains a container named Container1.
You add a composite index to the default indexing policy of Container1. The index has the following definition.
firstName ASC, age ASC
You plan to execute the following query against Container1.
SELECT *
FROM C
WHERE c.firstName = "John"
AND c.age > 21
AND c._ts < 1612213196
You need to optimize the performance of the query by adding an additional index.
How should you complete the additional index? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

Index components: [first] ASC age / firstName / _ts Index components: [second] DESC age / firstName / _ts Show answer
- Index components: [first] ASC firstName
- Index components: [second] DESC _ts
WhyA query with an equality filter and several range filters is optimized by one composite index per range property, each starting with the equality property. The existing index covers firstName and age, so add firstName then _ts. Direction on the range filter property does not affect this query.
- You have an Azure Cosmos DB Core (SQL) API account that is used by 10 web apps.
You need to analyze the data stored in the account by using Apache Spark to create machine learning models. The solution must NOT affect the performance of
the web apps.
Which two actions should you perform? Each correct answer presents part of the solution.
NOTE: Each correct selection is worth one point.- AIn an Apache Spark pool in Azure Synapse, create a table that uses cosmos.olap as the data source.
- BCreate a private endpoint connection to the account.
- CIn an Azure Synapse Analytics serverless SQL pool, create a view that uses OPENROWSET and the CosmosDB provider.
- DEnable Azure Synapse Link for the account and Analytical store on the container.
- EIn an Apache Spark pool in Azure Synapse, create a table that uses cosmos.oltp as the data source.
Show answer
Correct answer: A, D
WhyAzure Synapse Link with the analytical store gives a column store copy of the data that Spark can query without consuming RUs, so web apps are unaffected. In Spark, a table using cosmos.olap reads the analytical store. cosmos.oltp hits the transactional store and affects performance.
- A
- HOTSPOT
You have an Azure subscription that contains a resource group named RG1. RG1 contains an Azure Cosmos DB for NoSQL account named account1.
You plan to audit changes to the control plane of account1.
You need to ensure that audit events include the details of the security principal that performs each control plane change.
How should you complete the az command? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

az cosmosdb [dropdown] --name Account1 --resource-group RG1 service / sql / update --name Account1 --resource-group RG1 [dropdown] --analytical-storage-schema-type FullFidelity / --disable-key-based-metadata-write-access true / --network-acl-bypass None / --server-version 4.2 Show answer
- az cosmosdb [dropdown] --name Account1 --resource-group RG1 update
- --name Account1 --resource-group RG1 [dropdown] --disable-key-based-metadata-write-access true
WhyDisabling key-based metadata writes means control plane changes must go through Azure Resource Manager with Microsoft Entra identities, so audit logs record the security principal. Account keys carry no user identity. The setting is an account property, so it is changed with az cosmosdb update.
- You have an Azure subscription that contains the resources shown in the following table.

You need to store the account key of account1 in KV1.
What should you use?- Aa key
- Ba secret
- Ca certificate
Show answer
Correct answer: B
WhyAccount keys are strings, so they are stored in Key Vault as a secret. Keys are cryptographic keys used for wrap, unwrap and sign operations, and certificates are X.509 objects. A key vault secret can be referenced by apps without exposing the value.
- A
- You need to select the partition key for con-iot1. The solution must meet the IoT telemetry requirements.
What should you select?- Athe timestamp
- Bthe humidity
- Cthe temperature
- Dthe device ID
Show answer
Correct answer: D
WhyA good partition key has high cardinality and spreads writes evenly while matching common queries. Device ID gives many distinct values and fits per-device telemetry queries. Timestamp creates hot partitions for current writes, and humidity or temperature are measurements with few repeated values.
- A
- You need to identify which connectivity mode to use when implementing App2. The solution must support the planned changes and meet the business
requirements.
Which connectivity mode should you identify?- ADirect mode over HTTPS
- BGateway mode (using HTTPS)
- CDirect mode over TCP
Show answer
Correct answer: B
WhyGateway mode over HTTPS works through a single endpoint on port 443, so it suits apps behind restrictive firewalls or limited ports. Direct mode uses TCP across many ports and replicas, and direct mode over HTTPS is only for legacy cases. The case study context favors gateway mode.
- A
- You need to provide a solution for the Azure Functions notifications following updates to con-product. The solution must meet the business requirements and the
product catalog requirements.
Which two actions should you perform? Each correct answer presents part of the solution.
NOTE: Each correct selection is worth one point.- AConfigure the trigger for each function to use a different leaseCollectionPrefix
- BConfigure the trigger for each function to use the same leaseCollectionName
- CConfigure the trigger for each function to use a different leaseCollectionName
- DConfigure the trigger for each function to use the same leaseCollectionPrefix
Show answer
Correct answer: A, B
WhyMultiple change feed triggers can share one lease container (same leaseCollectionName) when each function uses a different leaseCollectionPrefix, so each function gets its own independent change feed checkpoints. Different lease collections would add cost, and the same prefix would make functions split the work.
- A