1
votes

I have created an Azure Function using CosmosDB Trigger template as per: this link

It's working fine, I can see updates flowing in from my Collection created in Cosmos DB.

enter image description here

Now the problem is, I want only those documents which are having actual updates. Currently If I update document using code it updates it's timestamp & document comes under update. Although there is no actual Data Update.

My questions:

  1. How can I only get Actual Updated documents(only those documents whose json fields are modified)?
  2. How can I also track deleted documents? they are not flowing here as well??
1
what do you mean by this: "if I update document using code"?silent
using azure java sdk to put data in cosmos collectionAnil Kapoor
so you mean you only want to get updates but not newly created documents?!silent
i want newly created documents, updates & delete as well. Ultimately trying to achieve CDC.Anil Kapoor
Please edit your question and describe what you mean by documents which are having actual updates. It would help if you include an example of the same.Gaurav Mantri

1 Answers

2
votes

1) Since any push to the document updates the - internally managed - _ts attribute, this still is a change to the overall document. If you changed the user data of the document does not matter here. The change feed does not know of this distinction. So you will always see those updates in the change feed as well.

2) Deletions are not added to the change feed but there is a possible workaround:

Currently change feed doesn’t log deletes. [...] you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted.

https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed#change-feed-and-different-operations