An azure function with signalR input binding can get some parameters. For example
[FunctionName("SignalRTest")]
public async Task SendMessage([SignalRTrigger]InvocationContext invocationContext, string message, ILogger logger)
{
logger.LogInformation($"Receive {message} from {invocationContext.ConnectionId}.");
}
In the function it can invoke the clients e.g.
[FunctionName("SendMessage")]
public static Task SendMessage(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
[SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
return signalRMessages.AddAsync(
new SignalRMessage
{
// the message will only be sent to this user ID
UserId = "userId1",
Target = "newMessage",
Arguments = new [] { message }
});
}
But is it possible for the azure function with input binding to return something?
I'd like to have
[FunctionName("SignalRTest")]
public async Task<string> SendMessage([SignalRTrigger]InvocationContext invocationContext, string message, ILogger logger)
{
return "123";
}
and
id = connection.invoke("SendMessage", "test");
but it does not seem to work.
Thank you.