Azure function audit log

Ian 1 Reputation point
2021-02-01T12:47:58.543+00:00

I'm learning CosmosDB, and have an azure function called with the new values of a row, whenever the row is updates.

I'm using that updated data to maintain a whole load of computed stuff in other collections.

Getting the new JSON's easy. It's the Input variable.

However is there anyway to get what it changed from. In dynamics crm, these were called pre and post images.

eg. here
if (input != null && input.Count > 0)
{
log.LogInformation("Documents modified " + input.Count);
log.LogInformation("First document Id " + input[0].Id);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(input[0]);
log.LogInformation(json);

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,678 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,543 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,591 Reputation points
    2021-02-03T06:03:59.62+00:00

    Hi @Ian , welcome to Microsoft Q&A forum.

    This can be achieved by using the Azure Cosmos DB Change feed but still we need to implement the versioning(revision history) of document by ourselves. As an example, first time a document is created we add a property 'version' with value 1. Any changes in this document, we copy this document and create another duplicate document with version as 2 and so on. Version 1 would always be the latest. Now while you are reading it in your code you can always go back to other versions and get that item and compare. A little extra work but the user voice which is developed mentioned the same (Refer)

    To answer your 2nd query, I would suggest you to read through the below link:
    https://stackoverflow.com/questions/60432921/cosmos-db-query-documents-by-time-interval-using-partition-key

    0 comments No comments