I've got a function with a CosmosDBTrigger
and I want to pipe notifications out to SignalR clients. The Cosmos trigger gives you an IEnumerable of items, which may belong to multiple different clients, I've tried returning a List<SignalRMessageAction>
but I get a serialization error. Is it possible to return multiple items from a function using [SignalROutput]
?
public class UpdatesAvailableFunction
{
[Function(nameof(UpdatesAvailableFunction))]
[SignalROutput(HubName = "serverless", ConnectionStringSetting = "AzureSignalRConnectionString")]
public List<SignalRMessageAction> UpdatesAvailable(
[CosmosDBTrigger(
databaseName: "%DatabaseName%",
collectionName: "%ContainerName%",
ConnectionStringSetting = "ConnectionString",
LeaseCollectionName = "leases",
LeaseCollectionPrefix = "UpdatesAvailable")]
IReadOnlyList<BrowserFeedNotification> input)
{
return input.Select(x => new SignalRMessageAction("updatesAvailable")
{
UserId = x.UserId
}).ToList();
}
}
The error message I'm getting is
[2022-11-04T11:01:32.319Z] Executed 'Functions.UpdatesAvailableFunction' (Failed, Id=b7ebfc4a-40cc-48ef-9f31-52c7c414daf3, Duration=15342ms) [2022-11-04T11:01:32.320Z] System.Private.CoreLib: Exception while executing function: Functions.UpdatesAvailableFunction. Microsoft.Azure.WebJobs.Extensions.SignalRService: Unable to convert JObject to valid output binding type, check parameters.