Azure / Azure/azure-functions-java-library

CosmosDB Outputbinding does not work for multiple documents

Open
#109 0 comments 0 reactions 0 assignees View on GitHub
area:java-functions
Dominant language
Java
Stars
45
Forks
49
PR merge metrics
No merged PRs in 30d

Description

We have a simple function which is triggered by event hub and simply forwards messages to cosmosDB using the cosmosDB output binding.
It works well if we receive and forward one message.
However it does not work when we receive and forward a list of messages using Cardinality.many.
Example:
```
public void run(
@EventHubTrigger(
name = "ConsumeDeviceMessages2",
eventHubName = "@eventhub.name@",
connection = "@iothub.connection@",
consumerGroup = CONSUMER_GROUP,
cardinality = Cardinality.MANY)
List messages,

@CosmosDBOutput(
name = "outputDocument",
databaseName = "@cosmosdb.name@",
collectionName = "@cosmosdb.collection.name@",
connectionStringSetting = "@cosmosdb.connection.appsetting@")
OutputBinding> outputDocument,

final ExecutionContext context) {
outputDocument.setValue(messages);
}
```
If this is triggered an error occurs:

`[Error] Executed 'Functions.SaveIotDeviceMessages' (Failed, Id=a845d74b-861a-40e7-a6f2-f5b7032b2cf2)Value cannot be null.Parameter name: document`

Configuration seems pretty basic and works on another function where we forward multiple messages to a queue instead.

Any idea why it is not working for cosmosDB? The documentation states its working for .NET and Javascript, no information about Java though.

Thanks and regards.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.