Sanjay Bhagia
Sanjay Bhagia

Reputation: 155

CosmosDBTrigger: Object reference not set to an instance of an object

When I try to execute newly created azure function with CosmosDBTrigger, I get the above exception for the function with cosmosdb trigger

Investigative information

Environment: Visual Studio 2017 15.3.5

Packages referenced:

Steps to reproduce the issue

Provide the steps required to reproduce the problem:

Here is the code sample

    public static class AddEventInEventStore
    {
        [FunctionName("AddEventInEventStore")]
        public static void Run([CosmosDBTrigger("db", "Items",
            ConnectionStringSetting = "AzureWebJobsDocumentDBConnectionString",
            LeaseCollectionName = "leases", LeaseDatabaseName = "db"
            )]
            IReadOnlyList<Document> changeList, TraceWriter log)
        {
            if (changeList != null && changeList.Count > 0)
            {
                log.Verbose("Documents modified " + changeList.Count);
                foreach (var change in changeList)
                {
                    log.Verbose("First document Id " + change.Id);
                }
            }

        }
    }

enter image description here

Upvotes: 3

Views: 1962

Answers (1)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35134

Update your Azure Functions and Web Jobs Tools (Tools -> Extensions and Updates).

I can see you are on 1.0.0 version (console title), while 1.0.4 is already available.

Upvotes: 3

Related Questions