Azure Cosmos DB – Change Feed, Stored Procedures and Triggers · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage

An application has a Cosmos DB pre-trigger named ValidateOrder. The developer expects the trigger to run automatically whenever any client creates an…

Practice question from Azure Cosmos DB – Change Feed, Stored Procedures and Triggers (AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage), with the correct answer and a step-by-step solution.

hard · MCQ · Q-A6D3B4

An application has a Cosmos DB pre-trigger named ValidateOrder. The developer expects the trigger to run automatically whenever any client creates an order in the container. What change is required to meet this expectation?

  1. A.Rename the trigger so that it begins with the prefix pre-.
  2. B.Configure the trigger as a database-level trigger in the Azure portal.
  3. C.Explicitly include ValidateOrder in the create-item request's pre-trigger options for every request that requires it.Correct answer
  4. D.Convert the pre-trigger to a change feed processor because triggers run only for updates.

Solution

Cosmos DB triggers are not automatically invoked for every matching operation. The client must explicitly specify the trigger in the request. A pre-trigger runs before the operation and can validate or modify the item before it is persisted.

More from Azure Cosmos DB – Change Feed, Stored Procedures and Triggers

All of Azure Cosmos DB – Change Feed, Stored Procedures and Triggers

Practise more Develop for Azure Storage

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed