1

I have setup up an Azure Function to trigger whenever there is a change in CosmosDB, thereby making it a CosmosDBTrigger. It seems the function is being called twice. I know this by looking into the monitor. The two calls occur within few minutes of each other.

I am not sure why the same function would get called twice or is there a setting somewhere to cause this?

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176
  • what exactly are you seeing ? – mugabits Mar 06 '19 at 04:19
  • I looked into ApInsights and I see the Function was triggered due to new changes. However, I know there was exactly one change, that is a new document added. The app copies this CosmosDB to a SQL table and the two rows resulting from the calls copies exactly the same thing. – Shamim Hafiz - MSFT Mar 06 '19 at 07:26

1 Answers1

0

The Trigger internally leverages the Cosmos DB Change Feed Processor Library, so your Function will receive batches of inserted / modified documents.

The size of the batch depends on the frequency of the operations. If you are inserting 1 document every second, your function might probably fire with a batch of 1 document several times; if you insert 10 documents every second, the batch will have those 10 documents. It's not a direct relationship with docs/second but just so you get the idea that the Function will always get a batch, and the batch size depends on the volume of operations.

DixitArora-MSFT
  • 1,768
  • 1
  • 5
  • 8
  • Thanks for the input, for my case the volume is low and typically one document every 24 hours. The two triggers occur very close in timing to each other. – Shamim Hafiz - MSFT Mar 06 '19 at 19:30