简体   繁体   中英

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?

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM