0
votes

I wonder if it is possible to fire a trigger after document is deleted from collection. To be more specific I'd like to be informed when a document expires.

I've seen that it isn't possible to catch deletes from change feed (https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed) but then I've downloaded cosmosdb emulator and here I see an option to create a trigger that can be fired on deletes. What is the difference between triggers created by user as seen in emulator and triggers fired on change feed? Is there any chance I could get a trigger for my needs?

1

1 Answers

0
votes

Currently there is no wait to archive what you want unless you use a server side post-trigger written in JavaScript.

However, in CosmosDB a trigger has to be explicitly called when the operation that will do the delete is invoked, which makes it less of a trigger and more of a stored-procedure-ish.

You can read more about that here: https://docs.microsoft.com/en-us/azure/cosmos-db/stored-procedures-triggers-udfs#post-triggers

Registered triggers don't run automatically when their corresponding operations (create / delete / replace / update) happen. They have to be explicitly called when executing these operations.

To learn more, see how to run triggers article.