The following code snippet has been taken from this Microsoft document:
[Function("SignalRFunction")]
[SignalROutput(HubName = "chat", ConnectionStringSetting = "SignalRConnectionString")]
public static MyMessage Run([SignalRTrigger("SignalRTest", "messages", "SendMessage", parameterNames: new string[] { "message" },
ConnectionStringSetting = "SignalRConnectionString")] string item,
[SignalRConnectionInfoInput(HubName = "chat")] MyConnectionInfo connectionInfo,
FunctionContext context)
{
var logger = context.GetLogger("SignalRFunction");
logger.LogInformation(item);
logger.LogInformation($"Connection URL = {connectionInfo.Url}");
var message = $"Output message created at {DateTime.Now}";
return new MyMessage()
{
Target = "newMessage",
Arguments = new[] { message }
};
}
public class MyMessage
{
public string Target { get; set; }
public object[] Arguments { get; set; }
}
What I'd like to do is to return multiple instances of MyMessage
simultaneously to send a message to different targets. Also, I'd like to return a JSON payload from Run
function comprising some other info e.g. a database record, etc.
How can the Run
function be augmented to support such a case?