All Microsoft exams
Free DP-420 practice test: 30 questions with answers
30 original questions for Building AI Applications with Azure Cosmos DB, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
All 30 DP-420 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Design and develop database solutions (10 questions)
Question 1
A globally distributed application must guarantee that reads never lag writes by more than five minutes or a fixed number of versions, while keeping latency lower than strong consistency. Which consistency level fits this requirement?
- AEventual
- BStrong
- CBounded staleness
- DConsistent prefix
Show answer and explanationHide answer
Correct answer: CBounded staleness lets the team configure a maximum lag in time or versions, which gives a predictable freshness guarantee with lower latency than strong. Eventual has no bound, and consistent prefix guarantees order but not a time limit.
Question 2
Which consistency level is the default when a new Azure Cosmos DB for NoSQL account is created?
- ASession
- BEventual
- CBounded staleness
- DStrong
Show answer and explanationHide answer
Correct answer: ASession is the default and guarantees read-your-own-writes for a client session. Strong and bounded staleness are stricter options, and eventual is weaker than the default.
Question 3
An application needs to retrieve one known item many times per second. Which operation is generally the least expensive in request units?
- AA point read using the item ID and partition key
- BA bulk delete of all items older than a year
- CA cross-partition query that filters on a non-indexed property
- DA full container scan with an ORDER BY on several fields
Show answer and explanationHide answer
Correct answer: AA point read addresses one item directly, which costs far fewer request units than queries that fan out or scan. Cross-partition queries, bulk deletes, and full scans all consume substantially more throughput.
Question 4
Which two statements about partition key selection are correct? (Choose two.)
- AA partition key should match the field most often used to filter single-partition queries
- BA low-cardinality partition key such as a boolean flag is ideal because it keeps data in few partitions
- CCross-partition queries are always cheaper than single-partition queries
- DA high-cardinality partition key spreads data and requests across many logical partitions
Show answer and explanationHide answer
Correct answer: A, DHigh cardinality and alignment with common filters both help distribute load and keep queries inside one logical partition. Low-cardinality keys create hot partitions, and cross-partition queries cost more than targeted ones.
Question 5
A multi-tenant application stores data for tenants, then users within each tenant, and needs efficient queries at both levels. Which partitioning feature is designed for this hierarchy?
- AA global secondary index on the user name
- BA single partition key with no hierarchy
- CHierarchical partition keys
- DManually splitting data into separate containers per tenant only
Show answer and explanationHide answer
Correct answer: CHierarchical partition keys let a container partition on up to three levels, such as tenant then user, which supports targeted queries at each level. Azure Cosmos DB does not use secondary indexes as a substitute for partitioning.
Question 6
A container's natural partition key has very few distinct values, which would create hot partitions. Which approach creates a better distribution without changing the source data model?
- AStoring every item under one fixed value in the partition key property
- BDuplicating the container for each country, with each copy in its own account
- CRemoving the partition key and relying on the container default for placement
- DA synthetic partition key that concatenates fields such as country and customer ID
Show answer and explanationHide answer
Correct answer: DA synthetic key combines existing fields into a higher-cardinality value that spreads writes while keeping the source fields intact. A single fixed value or a per-country duplication does not improve distribution in the same way.
Question 7
Which two conditions favor embedding related data inside a single item rather than referencing it in a separate container? (Choose two.)
- AChild records are updated independently and very frequently by many writers
- BThe same child records are shared across many unrelated parents
- CThe child data is almost always read together with its parent
- DThe number of child entries per parent is bounded and modest in size
Show answer and explanationHide answer
Correct answer: C, DEmbedding pays off when data is read together and the bounded size keeps the item within limits. Frequent independent updates and shared children favor separate items or references.
Question 8
A background service must read the change feed in batches on demand and keep its own position without managing leases or distributed coordination. Which change feed model fits best?
- AThe pull model with change feed iterators
- BA nightly export of the entire container
- CThe change feed processor with a lease container
- DA trigger that runs on every write synchronously
Show answer and explanationHide answer
Correct answer: AThe pull model lets the application request changes in batches using continuation tokens that it manages itself. The processor model handles distributed leases automatically, and triggers and nightly exports serve different purposes.
Question 9
When a change feed processor runs on several instances, what is the purpose of its lease container?
- AIt holds backup copies of the monitored source container so deleted or corrupted items can be restored after failures
- BIt stores checkpoints and lease ownership so that instances share the partition work and resume safely
- CIt stores the application's user profiles, session tokens, and preference documents read by the web front end tier
- DIt caches the results of recent change feed queries and read responses for client applications to lower request unit usage
Show answer and explanationHide answer
Correct answer: BThe lease container records which instance owns each partition range and where it stopped, which lets work be shared and resumed after failures. It does not hold application data, backups, or caches.
Question 10
An order workflow must create an order and its line items in one logical partition so that either all operations succeed or none are applied. Which feature provides this?
- ATransactional batch
- BA read-only snapshot query
- CSeparate point writes with retry on each call
- DBulk ingestion with partial success allowed
Show answer and explanationHide answer
Correct answer: ATransactional batch executes multiple operations against one logical partition atomically. Separate writes can leave partial results, and bulk ingestion tolerates partial success by design.
Secure, optimize, and deploy database solutions (10 questions)
Question 11
An application running in Azure must access Azure Cosmos DB without storing account keys in its configuration. Which approach is recommended?
- AUse the account connection string in a public GitHub repository with sample code files
- BShare the account's read-write key with every developer so each can test locally
- CEmbed the primary key in the compiled application binary so it ships with each release
- DUse a managed identity with Microsoft Entra ID authentication and disable key-based authentication
Show answer and explanationHide answer
Correct answer: DManaged identities with Entra ID remove long-lived secrets from application code and allow access to be governed by role assignments. Embedded or shared keys create exposure that identity-based access avoids.
Question 12
A reporting service needs read-only access to items in one container and must not be able to write data. Which control provides the narrowest appropriate permission?
- AGrant the service owner rights across the whole Azure subscription scope
- BGive the service the account's primary key to use for data access
- CAssign a data-plane role-based access control role that grants read access only
- DAllow read-write access to the container and rely on code to avoid unneeded writes
Show answer and explanationHide answer
Correct answer: CData-plane role-based access control assigns read-only data roles that can be scoped, which enforces least privilege. Full keys and subscription ownership grant far more than the service needs.
Question 13
Security policy requires that traffic to an Azure Cosmos DB account from a virtual network never traverses the public internet. Which configuration meets this requirement?
- AOpening inbound ports on the application's firewall to the account's public endpoint IP range
- BRouting traffic through a shared public proxy server in another subscription
- CA public endpoint with a longer connection string that uses a regional hostname
- DA private endpoint for the account in the virtual network, with public network access restricted
Show answer and explanationHide answer
Correct answer: DA private endpoint gives the account a private IP address inside the virtual network, and restricting public access enforces the policy. Public endpoints and open ports do not meet this requirement.
Question 14
A team must restore a container to the state it had 12 hours ago after a bad deployment corrupted data. Which backup configuration allows this?
- AA manual export written to a laptop each month
- BNo backup because replicas already protect against logical corruption
- CContinuous backup mode with point-in-time restore
- DPeriodic backup taken once a week only
Show answer and explanationHide answer
Correct answer: CContinuous backup with point-in-time restore lets the team recover to a chosen moment within the retention window, which covers logical corruption. Replicas copy bad writes too, so they do not protect against that failure.
Question 15
A global application requires writes in several regions with automatic failover if one region becomes unavailable. Which account configuration best supports this?
- AA separate account for every user
- BMulti-region writes with an automatic failover policy
- CA single write region with no failover configured
- DRead replicas that only accept writes after manual promotion each time
Show answer and explanationHide answer
Correct answer: BMulti-region writes allow each region to accept writes, and automatic failover keeps service available when a region fails. A single write region without failover leaves the service exposed to regional outages.
Question 16
A query on a large container costs many request units and is slow. The filter does not include the partition key. What is the first optimization to consider?
- ADisable indexing for the container by setting its mode to none in the policy
- BIncrease the number of client threads that run the query in parallel on one host
- CInclude the partition key in the filter so the query targets a single logical partition
- DReplace the query with several unfiltered reads issued in a sequential loop
Show answer and explanationHide answer
Correct answer: CFiltering on the partition key limits the query to one logical partition, which avoids fan-out and reduces cost. More threads add load without reducing work, and disabling indexing breaks efficient filtering.
Question 17
Which two actions help an application handle rate-limited responses (HTTP 429) from Azure Cosmos DB? (Choose two.)
- ADisabling retries so that the failed request is dropped silently
- BRetrying after the delay indicated by the service, using exponential backoff
- CRaising provisioned throughput or enabling autoscale when sustained demand requires it
- DRetrying immediately in a tight loop without any delay
Show answer and explanationHide answer
Correct answer: B, CThe service returns a retry-after hint, and honoring it with backoff avoids hammering the account. Throughput can be raised or autoscaled to meet sustained demand. Immediate tight retries and silent drops both make the problem worse or hide it.
Question 18
An operations team wants an alert when the account begins returning a sustained number of throttled requests. Which tool is designed to create this alert from platform metrics?
- AAzure Monitor metric alerts
- BA Git commit hook
- CA DNS health check on the application URL
- DA manual weekly review of the portal
Show answer and explanationHide answer
Correct answer: AAzure Monitor metric alerts evaluate platform metrics such as throttled request counts against thresholds and notify the team. Manual reviews, commit hooks, and DNS checks do not evaluate account metrics.
Question 19
A security team wants to limit an Azure Cosmos DB account so that only requests from specific public IP ranges are accepted. Which account setting provides this?
- AIP firewall rules
- BA larger provisioned throughput
- CA different default consistency level
- DThe number of read regions
Show answer and explanationHide answer
Correct answer: AThe IP firewall restricts which public addresses may connect to the account. Throughput, consistency, and region count do not control network access.
Question 20
An application in a secondary region should read from the closest replica to reduce latency, while writes still go to the write region. What capability does this rely on?
- ARead replicas in multiple regions with the client preferring the nearest region
- BA VPN tunnel that routes application traffic back to the primary region
- CHaving the client write each item separately into the other regions
- DDeleting replicated data from the secondary region on a schedule to reduce storage charges
Show answer and explanationHide answer
Correct answer: AAzure Cosmos DB replicates data to multiple regions, and the SDK can prefer the closest read region to lower latency. Client-side duplication and deleting data do not provide that, and a VPN to the primary region adds latency.
Implement AI and analytics capabilities in database solutions (10 questions)
Question 21
An application wants to store vector embeddings and query them with a vector index. Which container-level element must be defined when the container is created?
- AA separate Azure Cosmos DB account for each embedding dimension, each with its own throughput
- BA nightly script that regenerates the embeddings from the source documents and writes them back
- CA cloud-based image classifier hosted in Azure Machine Learning to tag photos
- DThe vector embedding policy that describes the vector path, dimensions, and data type
Show answer and explanationHide answer
Correct answer: DThe vector embedding policy and matching vector index are part of the container definition, which the vector search depends on. The other options are unrelated to the container configuration.
Question 22
A product catalog has millions of vectors, and the team needs approximate nearest-neighbor search that scales well beyond memory. Which vector index type is designed for large-scale search?
- AA hash index on the product name
- BDiskANN
- CA B-tree on the price
- DA linear scan of every item in the client
Show answer and explanationHide answer
Correct answer: BDiskANN is a graph-based approximate nearest-neighbor index that is designed for large vector collections. Hash and B-tree indexes do not support vector similarity search, and client-side scans do not scale.
Question 23
A query must rank documents by relevance to a set of keywords using full-text search. Which function returns the relevance score in Azure Cosmos DB for NoSQL?
- AST_Distance
- BCOUNT
- CVectorDistance
- DFullTextScore
Show answer and explanationHide answer
Correct answer: DFullTextScore returns a BM25-based relevance score for full-text search, which can be used for ranking. VectorDistance measures similarity between vectors, ST_Distance computes geospatial distance, and COUNT aggregates rows.
Question 24
A search feature needs to combine keyword matches with semantic similarity in one ranked result. Which technique combines the two result lists in a principled way?
- ASorting the combined results by document length alone
- BReciprocal rank fusion of the full-text and vector result rankings
- CAveraging raw keyword scores with raw distance values without normalization
- DTaking only the first ten keyword results and ignoring semantics
Show answer and explanationHide answer
Correct answer: BReciprocal rank fusion merges rankings from different retrieval methods without requiring their scores to be comparable, which is why it is common in hybrid search. Averaging unnormalized scores mixes incompatible scales.
Question 25
Which two components are combined in a retrieval-augmented generation (RAG) solution? (Choose two.)
- AA language model that generates an answer grounded in the retrieved passages
- BA permanent copy of the model's training data stored in every user session
- CA firewall rule that blocks all outbound requests
- DA retrieval step that finds relevant passages from indexed content
Show answer and explanationHide answer
Correct answer: A, DRAG retrieves relevant content and supplies it to a language model so that the answer is grounded in that content. Copying training data into sessions and firewall rules are not part of the RAG pattern.
Question 26
A chat assistant must keep each user's conversation history durable across sessions and expire old conversations automatically. Which design fits this requirement?
- AStore conversation items partitioned by session or user, with a time-to-live setting for expiry
- BKeep the conversation history in the browser's in-memory state for the current page
- CStore every user's conversation in one shared item so that every session writes to the same document partition
- DWrite the history to a rotating log file on the web server's local disk and parse it on demand for review
Show answer and explanationHide answer
Correct answer: APartitioning by session or user keeps related items together, and time-to-live removes stale conversations automatically. Browser memory is not durable, a shared item creates contention, and local log files are hard to query and expire.
Question 27
An embedding container must rank items by cosine similarity. Where is the similarity metric chosen?
- AIn the vector embedding policy for the container
- BIn the periodic backup retention and interval settings
- CIn the client's UI theme and color settings
- DIn the account's billing plan and cost allocation policy
Show answer and explanationHide answer
Correct answer: AThe distance function, such as cosine, euclidean, or dot product, is set in the vector embedding policy when the container is defined. The other settings are unrelated to similarity ranking.
Question 28
A container's vector policy declares 768 dimensions, but the embedding model returns 1536-dimension vectors. What is the most likely result?
- AThe service truncates each vector to its first 768 values, stores it, and returns success to the client
- BThe writes or vector queries fail because the vectors do not match the declared dimensions
- CThe container automatically updates its vector policy to accept 1536 dimensions on the next write request
- DThe embeddings are stored but excluded from the vector index used for similarity search queries
Show answer and explanationHide answer
Correct answer: BVector dimensions must match the policy the container was created with, so mismatched vectors are rejected. Silent truncation or automatic policy changes are not how the service behaves, and dimension mismatch is a configuration error to fix.
Question 29
A full-text search policy must apply the correct stemming and stop-word rules for the content. Which policy setting controls the default language?
- Athe client's preferred locale in the connection string
- Bthe partition key path
- CdefaultLanguage in the full-text policy
- DdefaultTtl in the container settings
Show answer and explanationHide answer
Correct answer: CThe full-text policy's default language determines how terms are tokenized and stemmed for search. TTL, connection locales, and partition paths do not affect language processing.
Question 30
An agent must remember durable facts about a user across many separate sessions, not just within one model prompt. Why store these facts in the database?
- AThe model context window keeps facts in memory across later sessions at no added token cost
- BDatabases automatically fine-tune the underlying model weights with each stored fact on write
- CFacts stored in the database can no longer be queried by the agent once the session closes
- DFacts persist beyond a single session and can be retrieved and updated reliably
Show answer and explanationHide answer
Correct answer: DA database gives durable, queryable storage that survives individual sessions and scales beyond a prompt window. Prompt context is temporary, and databases do not train models automatically.
Want more DP-420 questions?
The full bank has 100 questions with answers and explanations, as a PDF, an online practice exam, or both.
Both formats together. The best value.
Instant access after payment, with 90 days of updates. Checkout is on our store, AIExamCerts.