Azure Function not storing checkpoint and processing the same documents

2JK 241 Reputation points


I have an Azure Function that is triggered by a CosmosDB document insertion/update. When I run the function, it always captures the same item/document and runs from there. The continuation token in the leases container does not update. I thought if the function processes a certain document, it stores a checkpoint of that and knows where to continue from. Why is my function not doing that?

I have two function.json files (two functions), with each listening to a container but basically go through the same logic. I only have an input binding which is the CosmosDB trigger, and each has a different lease container. No output binding as I use the Cosmos client to upsert items into new containers I created in the same DB. I'm running my code locally in VSCode with python.

The function.json (the other is the same but with a different collectionName and leasesCollectionName):

  "scriptFile": "",
  "bindings": [
      "type": "cosmosDBTrigger",
      "name": "docs",
      "direction": "in",
      "leaseCollectionName": "leases",
      "connectionStringSetting": "cosmostest_DOCUMENTDB",
      "databaseName": "db-test",
      "collectionName": "collection-one",
      "createLeaseCollectionIfNotExists": true

Any help would be appreciated.

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

Accepted answer
  1. AnuragSingh-MSFT 20,991 Reputation points

    Hi @2JK ,

    Welcome to Microsoft Q&A! Apologies for the delay in getting back to this.

    The lease container maintains state across multiple and dynamic serverless Azure Function instances and enables dynamic scaling. Azure Functions (with "trigger type": "cosmosDBTrigger") gets automatically triggered on each new event in your Azure Cosmos container's change feed.

    Based on the symptom of issue reported, please refer to the document for "Common scenarios and workaround in Azure Cosmos DB Triggers". This contains common troubleshooting scenarios and corresponding measures to rectify them.
    Please let me know if you have any questions.
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

0 additional answers

Sort by: Most helpful