My customer would like to use a CosmosDBTrigger to transfer documents to an Azure Service Bus. In this scenario it's important to have a 1:1 relationship between Cosmos item mutations and Service Bus messages. So, each document that the trigger receives (via batch) must be processed only once, this leads to some fundamental questions I've been unable to confirm:
- What happens if the code throws an exception during processing? Will the batch simply be forgotten?
- Similarly if there is a runtime issue with the function service, or the CosmosDBTrigger library that causes an interruption prior to calling the Azure Function, can this be recovered without skipping the batch or duplicating documents?
- Is there any way for the function to report the completion status, such as "not processed"; causing the trigger to retry the batch?
- Are there circumstances where the same document will be processed multiple times, either by the same or a different instance? (I've read a couple of posts claiming this occurred.)
If the net answer is that this trigger is not reliable, just curious what are the intended use cases for its use?
Thanks
-John