Project moved to azure-sdk-for-net repo.
Package Name | Target Framework | NuGet |
---|---|---|
Microsoft.Azure.WebJobs.Extensions.SignalRService | .NET Core App 2.1 .NET Core App 3.1 |
These bindings allow Azure Functions to integrate with Azure SignalR Service.
SignalRConnectionInfo
input binding makes it easy to generate the token required for clients to initiate a connection to Azure SignalR Service.
SignalR
output binding allows messages to be broadcast to an Azure SignalR Service hub.
func init
func extensions install -p Microsoft.Azure.WebJobs.Extensions.SignalRService -v 1.0.0
AzureSignalRConnectionString
with the SignalR connection string.
local.settings.json
In order for a client to connect to SignalR, it needs to obtain the SignalR Service client hub URL and an access token.
negotiate
and use the SignalRConnectionInfo
input binding to obtain the connection information and return it. Take a look at this sample.negotiate
function as it's a normal SignalR hub. See this file for a sample usage.Binding schema:
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "<hub_name>",
"connectionStringSetting": "<setting_name>", // Defaults to AzureSignalRConnectionString
"direction": "in"
}
The SignalR
output binding can be used to broadcast messages to all clients connected a hub. Take a look at this sample:
Binding schema:
{
"type": "signalR",
"name": "signalRMessages", // name of the output binding
"hubName": "<hub_name>",
"connectionStringSetting": "<setting_name>", // Defaults to AzureSignalRConnectionString
"direction": "out"
}
To send one or more messages, set the output binding to an array of objects:
module.exports = function (context, req) {
context.bindings.signalRMessages = [{
"target": "newMessage", // name of the client method to invoke
"arguments": [
req.body // arguments to pass to client method
]
}];
context.done();
};
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.