Bruno Dias
Bruno Dias

Reputation: 149

Azure Functions Trigger Failed: A listener for function was unable to start

I'm creating an azure function with a cosmos db trigger, i used the visual studio code azure tools to create it and it generated the following code:

public static class offers_trigger
    {
        [Function("items_trigger")]
        public static void Run([CosmosDBTrigger(
            databaseName: "dev",
            collectionName: "items",
            ConnectionStringSetting = "dev_DOCUMENTDB",
            LeaseCollectionName = "leases")] IReadOnlyList<MyDocument> input, FunctionContext context)
        {
            var logger = context.GetLogger("items_trigger");
            if (input != null && input.Count > 0)
            {
                logger.LogInformation("Documents modified: " + input.Count);
                logger.LogInformation("First document Id: " + input[0].Id);
            }
        }
    }

But when I try to start it locally, it generates the following error:

The listener for function 'Functions.items_trigger' was unable to start. Microsoft.Azure.DocumentDB.Core: Sql api is not supported for this database account
ActivityId: 773dae99-5e4e-45f7-a54f-4c5b0dbaf5a8, Microsoft.Azure.Documents.Common/2.14.0, Darwin/10.15 documentdb-netcore-sdk/2.12.0.

Can anyone help me please?

Upvotes: 0

Views: 861

Answers (2)

jhoefnagels
jhoefnagels

Reputation: 379

We have had a similar issue that started to appear at a certain point in time without any changes to our function app. We were able to fix this issue by upgrading "Microsoft.Azure.WebJobs.Extensions.CosmosDB" nuget package to the latest version (3.0.10)

Upvotes: 1

Your using a Cosmos DB Binding for SQL API and the Cosmos DB account you specify doesn't support the SQL API. More info here

Upvotes: 1

Related Questions