Free DP-420 Exam Braindumps
Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB Questions 26–30 (page: 25)

Updated On: 16-Nov-2026
View Related Case Study

You have a global ecommerce application that stores data in an Azure Cosmos DB for NoSQL account. The account is configured for multi-region writes.
You need to create a stored procedure for a custom conflict resolution policy for a new container. In the event of a conflict caused by a deletion, the deletion must always take priority.
Which parameter should you check in the stored procedure function?

  1. isTombstone
  2. conflictingItems
  3. existingItem
  4. incomingItem

Answer(s): A

Explanation:

isTombstone: Boolean indicating if the incomingItem is conflicting with a previously deleted item.
When true, existingItem is also null.
Incorrect:
conflictingItems: Array of the committed version of all items in the container that are conflicting with incomingItem on ID or any other unique index properties.
existingItem: The currently committed item. This value is non-null in an update and null for an insert or deletes. incomingItem: The item being inserted or updated in the commit that is generating the conflicts. Is null for delete operations.


Reference:

https://docs.microsoft.com/en-us/azure/cosmos-db/sql/how-to-manage-conflicts



View Related Case Study

HOTSPOT (Drag and Drop is not supported)
You have an Azure Cosmos DB for NoSQL database named DB1 that hosts a container named Container1. The partition key for Container1 is /city.
You are developing a cloud-native app named App1 that will store customer information in DB1. App1 will perform transactional batch operations to update the items in Container1.
You need to configure App1 to meet the following requirements:
-Ensure that batch operations are rolled back if an item’s ETag value has changed since the value was last read.
-Ensure that all operations in the batch apply to a single partition key value.
How should you complete the C# code? To answer, select the appropriate options in the answer area.
Note: Each correct selection is worth one point.
Hot Area:

  1. See Explanation section for answer.

Answer(s): A

Explanation:




The logical flow for a transactional batch with ETag concurrency would look like this:
Initialize: TransactionalBatch batch = container.CreateTransactionalBatch(new PartitionKey("London")); Add Operation: batch.UpsertItem(item, new TransactionalBatchItemRequestOptions { IfMatchEtag = "etag1" }); Execute: using TransactionalBatchResponse response = await batch.ExecuteAsync(); container.CreateTransactionalBatch(new PartitionKey("London"));
Box 1: {IfMatchEtag='etag1'})
To ensure your transactional batch operations in Azure Cosmos DB for NoSQL adhere to Optimistic Concurrency Control (OCC), you must configure the TransactionalBatchRequestOptions to handle ETag checks.
Direct Code Answer
The TransactionalBatchRequestOptions should be declared as follows:
csharp
TransactionalBatchRequestOptions options = new TransactionalBatchRequestOptions
{
IfMatchEtag = "your-last-read-etag-value"
};
Box 2: ("London"));
To complete the line of your C# code based on the requirements for transactional batches in Azure Cosmos DB, you should use the partition key value that matches the items being processed.
The line should be completed as follows:
container.CreateTransactionalBatch(new PartitionKey("London"));
Code Breakdown container.CreateTransactionalBatch: This method initializes the batch operation.
new PartitionKey("London"): Transactional batches are scoped to a single logical partition. Since your UpsertItem uses "London" as the city (your partition key), the batch must be initialized with that specific value.
Atomicity: By using TransactionalBatch, Cosmos DB ensures that if any operation fails (including the ETag check), the entire batch is rolled back.


Reference:

https://medium.com/emerline-tech-talk/mastering-azure-cosmos-db-the-ultimate-guide-for-developers-7e4d6d2 9caff



View Related Case Study

HOTSPOT (Drag and Drop is not supported)
You have an Azure subscription that contains an Azure Cosmos DB for NoSQL account.
You run the following query.

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Note: Each correct selection is worth one point.
Hot Area:

  1. See Explanation section for answer.

Answer(s): A

Explanation:



Box 1: No
No - As written, the query will return results.
The code contains a significant type mismatch that will likely cause a runtime error during deserialization.
Why it might fail
While the query logic itself is technically valid, the implementation has one primary issue:
Type Mismatch (Critical): You are querying for last names (strings) from an employees container, but trying to deserialize them into a List<Cars>. Unless your Cars class can be initialized from a single string value (which is unlikely), response.AddRange(results) will fail.
To make this work for retrieving distinct last names, use a string type for the iterator:
// 1. Query definition is valid for Azure Cosmos DB NoSQL
QueryDefinition query = new QueryDefinition(
"SELECT DISTINCT VALUE e.lastname FROM employees e ORDER BY e.lastname"
);
string continuation = null;
List<string> lastNames = new List<string>(); // Use string instead of Cars
// 2. Specify the correct type <string> in the iterator using (FeedIterator<string> resultSetIterator = container.GetItemQueryIterator<string>(
query,
requestOptions: new QueryRequestOptions() { MaxItemCount = -1 }))
{
while (resultSetIterator.HasMoreResults)
{
// 3. Read results as strings
FeedResponse<string> response = await resultSetIterator.ReadNextAsync(); lastNames.AddRange(response);
if (response.Count > 0)
{
continuation = response.ContinuationToken;
break; // Exits after the first page of results
}
}
}
Box 2: No
No - The MaxItemCount parameter limits the number of results per query execution.
The MaxItemCount parameter does not strictly limit the total number of results; instead, it defines the maximum number of items returned in a single "page" (round trip) of the query execution.
Box 3: Yes
The ContinuationToken parameter is used to process queries from multiple pages.
The ContinuationToken is used to process queries from multiple pages. It acts like a "bookmark" that tells Cosmos DB where to resume fetching data in a subsequent request.
This specific query uses SELECT DISTINCT, which has strict requirements for pagination to work correctly. Key Requirements for Your Query
DISTINCT requires ORDER BY: In Azure Cosmos DB, you cannot use a continuation token with DISTINCT unless you also include an ORDER BY clause that matches the fields in this SELECT list.
Matching Fields: The query follows this rule: SELECT DISTINCT VALUE e.lastname ... ORDER BY e.lastname. Because the fields match, a continuation token will be generated.


Reference:

https://medium.com/@nick.chapsas/cosmosdb-fluent-pagination-with-cosmonaut-4806f67c26cf



View Related Case Study

You plan to implement an Azure Cosmos DB container that will store telemetry data from 1,000 IoT devices. The data will be updated once every minute. An app will read the data once daily and generate aggregated reports that summarize the state of each device.
You need to configure a partition key for the container. The solution must meet the following requirements:
-Minimize the possibility of reaching the partition limits.
-Spread read and write operations evenly across the partitions.
-Minimize how long it takes to locate a specific set of telemetry values.
To what should you set the partition key?

  1. the device ID and date
  2. the device ID
  3. the date and a random value
  4. the date

Answer(s): B

Explanation:

Azure Cosmos DB in IoT workloads
The partition key determines how Azure Cosmos DB routes data in partitions. The IoT Device ID is the usual partition key for IoT applications.
Incorrect:
* date
Would be the same during the whole day, which is not good.
Note: Use item ID [Device ID] as the partition key
If your container has a property that has a wide range of possible values, it's likely a great partition key choice. One possible example of such a property is the item ID. For small read-heavy containers or write-heavy containers of any size, the item ID (/id) is naturally a great choice for the partition key.
The system property item ID exists in every item in your container. You might have other properties that represent a logical ID of your item. In many cases, these IDs are also great partition key choices for the same reasons as the item ID.
The item ID is a great partition key choice for the following reasons:
There are a wide range of possible values (one unique item ID per item).
Because there's a unique item ID per item, the item ID does a great job at evenly balancing RU consumption and data storage.
You can easily do efficient point reads since you always know an item's partition key if you know its item ID.


Reference:

https://learn.microsoft.com/en-us/azure/architecture/solution-ideas/articles/iot-using-cosmos-db https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning-overview



View Related Case Study

HOTSPOT (Drag and Drop is not supported)
You are building an app that will use an Azure Cosmos DB for NoSQL container named Container1. Container1 will store the following data.

You plan to perform the following queries on Container1:
● Query1: Retrieve all the items for a tenantld value.
● Query2: Retrieve all the items for a tenantld value and a state value.
● Query3: Retrieve all the items for a tenantld value, a state value, and a city value.
You need to recommend partition keys for Container1. The solution must meet the following requirements:
● Minimize the number of queries that require a cross partition query.
● Minimize the amount of storage consumed by individual partitions.
Which partition key should you recommend for each requirement? To answer, select the appropriate options in the answer area.
Note: Each correct selection is worth one point.
Hot Area:

  1. See Explanation section for answer.

Answer(s): A

Explanation:



Box 1: tenantid\city\state
The best partition key for the container is tenantid (or tenantid/state/city if using hierarchical partition keys).
1. Partition Key Selection Strategy
To minimize cross-partition queries, the partition key must be included as a filter in all your targeted queries. Looking at the requirements:
Query1 filters by tenantid
Query2 filters by tenantid and state
Query3 filters by tenantid, state, and city
Because tenantid is the only property present in every single query, it must be the primary component of your partition key.
Box 2: tenantid\state\city
The combination of tenantid, state, and city (or a synthetic key combining them, like tenantid_state_city) is the best partition key strategy to minimize individual partition storage.
Maximum Granularity: Azure Cosmos DB distributes data based on the distinct values of the partition key. Combining all three properties creates the highest number of unique logical partitions, which keeps the data size of each individual partition as small as possible.
Query Efficiency: All three of the target queries (Query1, Query2, and Query3) include the tenantid filter. By using a hierarchical partition key or a composite synthetic key starting with tenantid, you ensure that none of these queries become expensive cross-partition scans.


Reference:

https://www.c-sharpcorner.com/article/partitioning-in-cosmos-db/



Viewing page 25 of 61
Viewing questions 121 - 125 out of 296 questions


Post your Comments and Discuss Microsoft DP-420 exam prep with other Community members:

AI Tutor AI Tutor 👋 I’m here to help!