Reputation: 30727
I have set up a SignalR Service account in Azure.
I have set this to Serverless.
I have set the Upstream URL to https://THE-NAME-OF-MY-FUNC-APP.azurewebsites.net/runtime/webhooks/signalr?code=THE-DEFAULT-KEY-FROM-FUNC-APP-APPKEYS_HOST_DEFAULT
This is documented here, under Rule Settings: https://learn.microsoft.com/en-us/azure/azure-signalr/concept-upstream#rule-settings
I have an AZ Functions App created in Node/TypeScript where I have a function that has a SignalRTrigger in and an SignalRMessages out. Consider the following function.
function.js
{
"bindings": [
{
"type": "signalRTrigger",
"name": "invocation",
"hubName": "mailbox",
"category": "messages",
"event": "heartbeat",
"connectionStringSetting": "AzureSignalRConnectionString",
"parameterNames":[
"mailboxId"
],
"direction": "in"
},
{
"type": "signalR",
"name": "signalRMessages",
"hubName": "mailbox",
"connectionStringSetting": "AzureSignalRConnectionString",
"direction": "out"
}
],
"scriptFile": "../dist/heartbeat/index.js"
}
And the index.js
import { AzureFunction, Context } from "@azure/functions"
const heartbeatTrigger: AzureFunction = async function (context: Context, invocation: any): Promise<void> {
context.log.info('Heartbeat function executed');
let mbid = context.bindingData.mailboxId;
// output a hearbeat received
context.bindings.signalRMessages = [{
"target": "heartbeatReceived",
"arguments": [mbid]
}];
};
export default heartbeatTrigger;
When I use the @aspnet/signalr client in a Vue app I can connect to the SignalR hub.
When I try to use myConnection.send('heartbeat', '123')
I expect the above function to get called.
This is not happening. I do not seem to be able to fire the function.
Can someone please help?
Upvotes: 7
Views: 1610
Reputation: 30727
I've spent days on this.
Finally came across this document on GitHub
THIS explains how to get it all working - the big piece was the key that needs to be used. Signalr_extension!
Upvotes: 7