DP-420 Azure Cosmos DB Study Guide & Exam Questions

Free practice exam

DP-420 Practice Exam: 20 Free Exam Questions

Test yourself on 20 exam questions picked from every domain of the study guide. You get your score per domain at the end, with every answer explained.

  • 20 exam questions
  • 3 domains
  • About 25 minutes
  • No account needed

One question at a time, like the real exam: results and explanations come after the last question. Nothing you answer is saved.

What the exam covers

Exam domainExam questions
1. Part 1: Throughput, Consistency, SDK Operations, Queries, Partitioning and Change Feed10
2. Part 2: Security, Backup, Multi-Region Failover, Indexing, Monitoring and Fleets8
3. Part 3: Full-Text, Vector and Hybrid Search, RAG, Agent Memory and Fabric Analytics2

The 20 exam questions

Read them through, or start the exam to answer them and see how you score.

An account at session consistency serves six apps, spans one write region plus ten read regions, and sees hourly updates to roughly a fifth of items. People using the new app from several gadgets must observe identical values everywhere without disturbing the other apps.

1. Which two moves give cross-device consistency while leaving other apps untouched?
  • Lower the account default to eventual.
  • Tie a session token to each gadget.
  • Rely on implicit session handling for reads.
  • Send the saved session token with read calls.
  • Tie a session token to the user identity.

A sales order holds one line whose quantity is 10. It must become 5 with a patch that carries value -5.

{
    "id": "SalesOrder1",
    "PONumber": "P01",
    "OrderDateTime": "2022-11-21T00:00:00.0000000Z",
    "AccountNumber": "Acc1",
    "Items": [{"Id": 1, "OrderQty": 10, "ProductCode": "A111", "UnitPrice": 29.99}]
}
2. Send [ { "op": ____, "path": ____, "value": -5 } ] to reach 5 from 10.
  • /Items[0]/OrderQty
  • /Items/0/OrderQty
  • /Items/1/OrderQty
  • add
  • incr
  • increment
  • remove

Code using the SDK must substitute a document while applying optimistic concurrency.

3. Set the ____ property of ItemRequestOptions and compare the ____ document property.
  • _etag
  • _id
  • _rid
  • ConsistencyLevel
  • IfMatchEtag
  • SessionToken

One container holds parents, children, and pets as individual documents. All members of a household carry the same familyId key. Several members sharing an address must have that address revised together.

  • The change must be atomic, consistent, isolated, and durable
  • Delay must be as small as possible
4. Which method meets both demands?
  • Revise every member with its own patch call.
  • Revise every member separately while demanding strong consistency.
  • Revise every member together in one transactional batch.

An app issues searches that yield very large answer sets. Pages of 80 items must be handed back until the full set is delivered.

5. In which sequence should the paging steps be carried out?
  • Add each page payload to the accumulated variable
  • Execute the query and retain its continuation token
  • Set MaxItemCount to 80 in the query options

A container named account stores balance histories per account. One illustration follows. The goal is to list identifiers where any recorded balance went below zero.

{
  "id": "account-2022080712345",
  "balanceStatus": [
    {"balance": 1000, "datestamp": "2021-09-15T23:14:25.7251173Z"},
    {"balance": -10, "datestamp": "2021-09-11T19:16:25.1343234Z"},
    {"balance": 100, "datestamp": "2021-08-14T21:13:39.8121133Z"}
  ]
}
6. Complete SELECT c.id FROM c WHERE EXISTS( SELECT n FROM ____ WHERE ____ < 0 ) to find accounts that ever went negative.
  • c.balanceStatus
  • c.balanceStatus.balance
  • n < 0
  • n IN c.balanceStatus
  • n.balance
  • n.balanceStatus.balance

An orders container keyed on customerId holds documents like the one below. You must report total items ordered per month by item type as fast as possible with minimal RUs.

{
    "orderId" : "d4a9179b-5ead-43a3-b851-add9a71ac4b6",
    "customerId" : "f6e39103-bdc7-4346-9cfb-45daa4b2becf",
    "orderDate" : "2021-09-29",
  "orderItems" : [
    {
     "itemId" : "6c30412f-3cd7-4cab-813c-05942345720d",
     "name" : "blue pen",
     "type" : "pens",
     "count" : 10
    }
  ],
  "total" : 12345,
  "status" : "ordered"
}
7. What approach should you implement?
  • Configure the report to query orders by using a SQL query.
  • Configure the report to query a new aggregate container. Populate the aggregates by using the change feed.
  • Configure the report to query orders by using a SQL query through a dedicated gateway.
  • Configure the report to query a new aggregate container. Populate the aggregates by using SQL queries that run daily.

You are creating a container in DB1 for a SaaS app that stores customer and order details per vendor.

  • Each vendor has a distinct tenant identifier.
  • Reads must be as efficient as possible.
  • A customer identifier may repeat across vendors but must be distinct within one vendor.
  • Concurrent queries from many customers each fetch data for one vendor.
8. How should you configure the container?
  • Add a partition key to the tenant ID and a unique key policy to the customer ID.
  • Add hierarchical partition key on (tenant identifier, customer identifier).
  • Add a partition key to the customer ID and a unique key policy to the tenant ID.
  • Add hierarchical partition key on (customer identifier, tenant identifier).

A container keeps order items up to 2 KB. About one million orders arrive per day and shoppers often revisit their own history. Using orderDate as the key is under review.

{
    "orderId" : "d4a9179b-5ead-43a3-b851-add9a71ac4b6",
    "customerId" : "f6e39103-bdc7-4346-9cfb-45daa4b2becf",
    "orderDate" : "2021-09-29",
    "orderItems" : [...],
    "total" : 12345
}
9. What two consequences follow from keying by orderDate?
  • The count of distinct key values would breach the allowed maximum.
  • Stored bytes would breach the per-partition maximum.
  • One partition would constantly run hot.
  • Lookups would fan out across partitions.

A web farm will cooperatively drain a container change feed with the SDK processor, sharing partitions across many instances despite spiky update volume.

10. Which three settings distribute the feed correctly?
  • Configure the same processor name for all the instances
  • Configure a different processor name for each instance
  • Configure a different instance name for each instance
  • Configure a different lease container configuration for each instance
  • Configure the same instance name for all the instances
  • Configure the same lease container configuration for all the instances

User1 must be able to add items to container1, with no broader rights than necessary under least privilege using role-based access control.

11. Which role assignment satisfies the insert requirement with least privilege?
  • CosmosDB Operator only
  • DocumentDB Account Contributor and Cosmos DB Built-in Data Contributor
  • DocumentDB Account Contributor only
  • Cosmos DB Built-in Data Contributor only

Backups for account1 run every 2 hours and are kept for 4 days under periodic mode, where two copies are free and the remainder incur storage fees.

12. How many retained backup copies attract extra charges?
  • 8
  • 12
  • 46
  • 48

An account with one write region and one read region uses automatic failover. Its four connection strings share one global endpoint but hold different keys, as shown.

{
  "connectionStrings": [
    {
      "connectionString":
      "AccountEndpoint=https://constosodbaccount.documents.azure.com:443/;
      AccountKey=MwUgRnGti4vErT2rfPPFdTFFyI9KyI9Kbe1RPGv7OQdHo6VZ2i45TcJzrd4J80zYxrEATzyZh0m1nJaNFA==;",
      "description": "Primary SQL Connection String"
    },
    {
      "connectionString":
      "AccountEndpoint=https://constosodbaccount.documents.azure.com:443/;
      AccountKey=gfThRnGti4vErT2rfPPFdTFFyI43529Kbe1RPGv7OQdHo6VZ2i45TcJzrd4J80zYxrfatzyZh0m1nJaNFA==;",
      "description": "Secondary SQL Connection String"
    },
    {
      "connectionString":
      "AccountEndpoint=https://constosodbaccount.documents.azure.com:443/;
      AccountKey=WGykBc1PHJoos6MdErT2rfPPFx9yI9Kbe1RPGv7OQ1IQwQNxq6QdOXjxgyLLebXBp8uJu7FyJy3Uv1vuK2A==;",
      "description": "Primary Read-Only SQL Connection String"
    },
    {
      "connectionString":
      "AccountEndpoint=https://constosodbaccount.documents.azure.com:443/;
      AccountKey=k2DZI0oY4Jc7QeUJqVGH3csda6EyI9Kbe1RPGv7OQErT2rfPPFtbwTPfKAg19zVxC0MDNn8xPpQrednVYcQ==;",
      "description": "Secondary Read-Only SQL Connection String"
    }
  ]
}
13. After the write region fails, writers must switch to a different connection string to stay connected.
  • True
  • False
14. The two read-only strings connect to different regions for an app in East US.
  • True
  • False
15. Apps may pick read regions through the PreferredLocations connection setting.
  • True
  • False

You have enabled multi-region writes on account1 and must finish client setup.

16. Which two actions should you take next?
  • Set ApplicationRegion to the name of the deployed region.
  • Set UseMultipleWriteLocations to True.
  • Set consistencyLevel to Eventual.
  • Update connectionString.

A sensor query filters on device equality plus two range comparisons over value and timestamp as shown.

SELECT * FROM c
WHERE c.sensor = "TEMP1"
AND c.value < 22
AND c.timestamp >= 1619146031231
17. Which composite strategy minimizes RUs for this shape?
  • a composite index for (sensor ASC, value ASC) and a composite index for (sensor ASC, timestamp ASC)
  • a composite index for (sensor ASC, value ASC, timestamp ASC) and a composite index for (sensor DESC, value DESC, timestamp DESC)
  • a composite index for (value ASC, sensor ASC) and a composite index for (timestamp ASC, sensor ASC)
  • a composite index for (sensor ASC, value ASC, timestamp ASC)

An account named account1 streams its logs to Workspace1. The busiest operations by RU/s over the past day must be surfaced.

18. Run ____ | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category==____ | where TimeGenerated >= ago(1d) | summarize max(requestCharge_s) by OperationName to rank RU use.
  • "ControlPlaneRequests"
  • "DataPlaneRequests"
  • "PartitionKeyStatistics"
  • AzureActivity
  • AzureDiagnostics
  • AzureMetrics

Operational users suffer slowdowns whenever analysts fire heavy Spark queries directly at the transactional database.

19. What isolates analytics impact from operational traffic?
  • Mirroring into Microsoft Fabric
  • a default consistency level of Consistent Prefix
  • a default consistency level of Strong
  • the Azure Cosmos DB Spark connector

A NoSQL account hosts a Customers container. From a notebook in Microsoft Fabric, you will insert new customer rows into it with the Azure Cosmos DB Spark connector using the DataFrame shown.

newCustomers = spark.createDataFrame((\
     ("ABC001", "ABC Corporation", 0, True),\
     ("BEL001", "BEL Corporation", 20000, False)))\
         .toDF("id", "companyName", "creditLimit", "isOnCreditHold")
newCustomers.write\
      .format [Box 1]
      .options(**cfg)\
      .mode [Box 2]
      .save()
20. The write format to target Cosmos DB transactional storage is ____ and the save mode that adds rows without deleting existing data is ____.
  • ("APPEND")
  • ("cosmos.oltp")
  • ("CSV")
  • ("INSERT")
  • ("JSON")
  • ("PARQUET")