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.

  1. Question 1Multiple responseTopic 1
    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.
    1. A
      Append pre to the name of the JavaScript function trigger.
    2. B
      For each create request, set the access condition in RequestOptions.
    3. C
      Register the trigger as a pre-trigger.
    4. D
      For each create request, set the consistency level to session in RequestOptions.
    5. E
      For each create request, set the trigger name in RequestOptions.
    Show answer

    Correct answer: C, E

    Why

    The 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.

  2. Question 2HotspotTopic 1
    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 namedefaultTimeToLive / ttl / _ttl
    Property value-1 / 2 / 120 / 7200
    Show answer
    • Property name ttl
    • Property value 7200
    Why

    An 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.

  3. Question 3Single choiceTopic 2
    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?
    1. A
      logical partitions
    2. B
      physical partitions
    3. C
      databases
    4. D
      containers
    Show answer

    Correct answer: A

    Why

    Transactions 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.

  4. Question 4HotspotTopic 2
    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 cosmosdbfailover-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
    Why

    az 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.

  5. Question 5HotspotTopic 3
    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
    Why

    Deterministic 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.

  6. Question 6Single choiceTopic 3
    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?
    1. A
      Azure Migrate
    2. B
      Azure Data Factory
    3. C
      Database Migration Assistant
    Show answer

    Correct answer: B

    Why

    Azure 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.

  7. Question 7Single choiceTopic 3
    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?
    1. A
      Yes
    2. B
      No
    Show answer

    Correct answer: B

    Why

    No. 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.

  8. Question 8Single choiceTopic 4
    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?
    1. A
      Create a single container that stores author items and book items, and then items that represent the relationship between the authors and their books.
    2. B
      Create 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.
    3. C
      Create 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.
    4. D
      Create 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

    Why

    Embedding 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.

  9. Question 9HotspotTopic 4
    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] ASCage / firstName / _ts
    Index components: [second] DESCage / firstName / _ts
    Show answer
    • Index components: [first] ASC firstName
    • Index components: [second] DESC _ts
    Why

    A 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.

  10. Question 10Multiple responseTopic 5
    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.
    1. A
      In an Apache Spark pool in Azure Synapse, create a table that uses cosmos.olap as the data source.
    2. B
      Create a private endpoint connection to the account.
    3. C
      In an Azure Synapse Analytics serverless SQL pool, create a view that uses OPENROWSET and the CosmosDB provider.
    4. D
      Enable Azure Synapse Link for the account and Analytical store on the container.
    5. E
      In an Apache Spark pool in Azure Synapse, create a table that uses cosmos.oltp as the data source.
    Show answer

    Correct answer: A, D

    Why

    Azure 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.

  11. Question 11HotspotTopic 5
    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 RG1service / 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
    Why

    Disabling 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.

  12. Question 12Single choiceTopic 5
    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?
    1. A
      a key
    2. B
      a secret
    3. C
      a certificate
    Show answer

    Correct answer: B

    Why

    Account 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.

  13. Question 13Single choiceTopic 6
    You need to select the partition key for con-iot1. The solution must meet the IoT telemetry requirements.
    What should you select?
    1. A
      the timestamp
    2. B
      the humidity
    3. C
      the temperature
    4. D
      the device ID
    Show answer

    Correct answer: D

    Why

    A 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.

  14. Question 14Single choiceTopic 7
    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?
    1. A
      Direct mode over HTTPS
    2. B
      Gateway mode (using HTTPS)
    3. C
      Direct mode over TCP
    Show answer

    Correct answer: B

    Why

    Gateway 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.

  15. Question 15Multiple responseTopic 8
    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.
    1. A
      Configure the trigger for each function to use a different leaseCollectionPrefix
    2. B
      Configure the trigger for each function to use the same leaseCollectionName
    3. C
      Configure the trigger for each function to use a different leaseCollectionName
    4. D
      Configure the trigger for each function to use the same leaseCollectionPrefix
    Show answer

    Correct answer: A, B

    Why

    Multiple 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.