Question 6 of 138

You are designing an Azure Cosmos DB Core (SQL) API solution to store data from IoT devices. Writes from the devices will be occur every second.

The following is a sample of the data.

You need to select a partition key that meets the following requirements for writes:

✑ Minimizes the partition skew

✑ Avoids capacity limits

✑ Avoids hot partitions

What should you do?

    Correct Answer: D

    Using a synthetic key that combines deviceId with a random number is beneficial for this scenario as it helps to distribute write operations evenly across multiple partitions. This approach minimizes the chances of hitting capacity limits and avoids creating hot partitions, where one partition might receive significantly more writes than others. Options involving timestamp, sensor1Value, or deviceManufacturer could still lead to uneven data distribution, causing hot partitions or partition skew.

Question 7 of 138

You maintain a relational database for a book publisher. The database contains the following tables.

The most common query lists the books for a given authorId.

You need to develop a non-relational data model for Azure Cosmos DB Core (SQL) API that will replace the relational database. The solution must minimize latency and read operation costs.

What should you include in the solution?

    Correct Answer: C

    The most optimal approach to minimize latency and read operation costs in this scenario is to create a container that contains a document for each Author and a document for each Book, and then embed the authorId in each Book document. This design takes advantage of Cosmos DB's ability to store related entities within the same container and makes querying more efficient, especially for the most common query, which lists books by a given authorId. Embedding authorId in each Book document keeps the data structure simple and avoids the complexities and potential overhead associated with multiple containers or cross-container joins.

Question 8 of 138

You have an Azure Cosmos DB Core (SQL) API account.

You run the following query against a container in the account.

What is the output of the query?

    Correct Answer: A

    The IS_NUMBER function in Azure Cosmos DB returns a Boolean value indicating whether the specified expression is a number. For the given query: IS_NUMBER('1234') evaluates to false because '1234' is a string, not a number. IS_NUMBER(1234) evaluates to true because 1234 is a number. IS_NUMBER({prop: 1234}) evaluates to false because the argument provided is an object, not a number. Therefore, the output of the query is [ {"A": false, "B": true, "C": false} ].

Question 9 of 138

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.

    Correct Answer: C, E

    To ensure that a trigger runs before an item is inserted into a container in Azure Cosmos DB Core (SQL) API, you need to register the trigger as a pre-trigger and set the trigger name in RequestOptions for each create request. Registering the trigger as a pre-trigger ensures it is configured to run before the insertion operation. Setting the trigger name in RequestOptions ensures that the trigger is actually executed during the specific operation.

Question 10 of 138

HOTSPOT -

You have a container in an Azure Cosmos DB Core (SQL) API account.

You need to use the Azure Cosmos DB SDK to replace a document by using optimistic concurrency.

What should you include in the code? To answer, select the appropriate options in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

    Correct Answer:

    Box 1: ConsistencyLevel -

    The ItemRequestOptions Class ConsistencyLevel property gets or sets the consistency level required for the request in the Azure Cosmos DB service.

    Azure Cosmos DB offers 5 different consistency levels. Strong, Bounded Staleness, Session, Consistent Prefix and Eventual - in order of strongest to weakest consistency.

    Box 2: _etag -

    The ItemRequestOptions class helped us implement optimistic concurrency by specifying that we wanted the SDK to use the If-Match header to allow the server to decide whether a resource should be updated. The If-Match value is the ETag value to be checked against. If the ETag value matches the server ETag value, the resource is updated.

    Reference:

    https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.itemrequestoptions https://cosmosdb.github.io/labs/dotnet/labs/10-concurrency-control.html