I am building an application based on serverless architecture. The part, where i am stuck includes: SPA Web UI, C# .Net 5.0 isolated process Function (dotnet-isolated), Azure SignalR Service (serverless mode).
There is a lot of documentation and examples how to build different real-time serverless apps using the the same stack i mentioned, but with .Net 3.1 Functions. And almost none information about SignalR output bindings for .Net 5.0 isolated process Functions triggered by SignalR.
The only helpful documentation out there is the following: C# isolated process: https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide SignalR Extension: https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/Extensions/SignalR
So, basics are covered there. But, there is no information about some advanced SignalR output bindings, that will help to build some more functions like: Add User To Group, Remove User From Group. Etc.
So far i was able to build and run: Negotiate, SendMessage (to all, user or group) , Connected, Disconnected
But i am struggling with AddToGroup part... Here is my code:
[Function(nameof(AddToGroup))]
[SignalROutput(HubName = "WebUINotifications", ConnectionStringSetting = "AzureSignalRConnectionString")]
public static OutputObject AddToGroup(
[SignalRTrigger("WebUINotifications", "messages", "AddToGroup")] string item,
FunctionContext context)
{
var logger = context.GetLogger("AddToGroup");
var signalrGroup = JsonSerializer.Deserialize<SignalRGroup>(item);
var userId = signalrGroup.UserId;
var groupName = signalrGroup.Arguments[0];
logger.LogInformation($"UserId: {userId}");
logger.LogInformation($"Group Name: {groupName}");
return new OutputObject()
{
UserId = userId,
GroupName = groupName,
};
}
After configuring UpStream settings for SignalR Service in Azure, my function gets triggered successfully by javascript from Web UI
this.connection.invoke('AddToGroup', 'TestGroup');
But i get the error, which is not surprising at all, because it is not clear how exactly to bind:
System.Private.CoreLib: Exception while executing function: Functions.AddToGroup. Microsoft.Azure.WebJobs.Extensions.SignalRService: Unable to convert JObject to valid output binding type, check parameters.
What am i missing? Where to find documentation?
Thanks guys!