toshiomagic
toshiomagic

Reputation: 1649

Cosmos DB Trigger not working due to binding error

I have a cosmos db and I want to use it to trigger an azure function.

When I do, I get this error:

A ScriptHost error has occurred
Exception while executing function 
Exception binding parameter 'documents'.
Binding can only be done with IReadOnlyList<Document> or JArray
Parameter name: type.

Supposedly the reason for this is because I'm referencing Azure.DocumentDB Nuget package version 2.0.0 because the entire rest of my codebase uses it. This version conflicts with the version referenced by Azure.WebJobs.Extensions.DocumentDB which is DocumentDB 1.13.2.

Azure.WebJobs.Extensions.DocumentDB is the package that contains the CosmosDBTrigger attribute which I need to trigger the function. So it's a must have.

How do I get around the conflict between DocumentDB 1.13.2 and 2.0.0? I think it is absolutely ridiculous that Microsoft doesn't support Cosmos DB Triggers with the latest DocumentDB.

Upvotes: 0

Views: 907

Answers (1)

Matias Quaranta
Matias Quaranta

Reputation: 15583

Azure Functions has 2 Runtime versions, V1, and V2.

If you work with Azure Functions V1, then, the dependency is with SDK 1.13.2, the reason is because Azure Functions V1 does not support binding redirects (more details in https://github.com/Azure/azure-functions-host/wiki/Assembly-Resolution-in-Azure-Functions#assembly-resolution-in-azure-functions-10).

You can also choose to work with Azure Functions V2, which has a different Extension packages and different features. The version of the SDK in Functions V2 is near the latest. Here are the official docs for V2: https://learn.microsoft.com/azure/azure-functions/functions-bindings-cosmosdb-v2#packages---functions-2x

With Functions V2 you will already have the SDK 2.X.

Upvotes: 1

Related Questions