question

Shanky2023-5342 avatar image
0 Votes"
Shanky2023-5342 asked Shanky2023-5342 commented

Azure cosmos db selective change feed processing logic

Hi, I am reading cosmosdb change feed and want to implement about processing logic that will not run based on any trigger. It will run if I run some application. Is it possible? Do cosmosdb keep track of records for days or it is real time. Like if I don't capture record at the time of changing will it lose those records?

Also I cannot find any example of code for python. Can you point me to it.

I also want to know when is it good to use change feed or any easy alternative to it?

azure-cosmos-db
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSharma-MSFT avatar image
0 Votes"
AnuragSharma-MSFT answered Shanky2023-5342 commented

Hi @Shanky2023-5342, welcome to Microsoft Q&A forum.

As I understand you want to know if change feed logic can be used without a trigger and any time we run any code manually, it should bring all the changed documents.

Yes as per the article, " Change feed in Azure Cosmos DB is a persistent record of changes to a container in the order they occur". This means the records will be persisted and we don't need a trigger to read real time changes as they can be read later also based on your requirements. Also if a TTL (Time to Live) property is set on an item to -1, change feed will persist forever. If the data is not deleted, it will remain in the change feed.

I would request you to once go through the article mentioned above as well as below article that talks about some use cases where we can prefer the Change feed:

Change feed design patterns in Azure Cosmos DB

Change feed is not only limited to SQL API but can also be used for Mongo DB and Cassandra API in Azure Cosmos DB.

While you are going through the change feed you can also refer to this article that nicely sums up multiple documentation and provider more insights:

Change Feed – Unsung Hero of Azure Cosmos DB

Coming to example on python, refer to the article:

Get the change feed of items in a container

Please let us know if this helps or else we can discuss it further.


If answer is helpful please click on 202704-image.png as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions. Thank you for helping to improve Microsoft Q&A!



image.png (4.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, will check and get back.

0 Votes 0 ·