azure-signalr-dev - Microsoft.Azure.SignalR.Serverless.Protocols 1.3.0
Package Description
PM> Install-Package Microsoft.Azure.SignalR.Serverless.Protocols -Version 1.3.0 -Source https://www.myget.org/F/azure-signalr-dev/api/v3/index.json
> nuget.exe install Microsoft.Azure.SignalR.Serverless.Protocols -Version 1.3.0 -Source https://www.myget.org/F/azure-signalr-dev/api/v3/index.json
> dotnet add package Microsoft.Azure.SignalR.Serverless.Protocols --version 1.3.0 --source https://www.myget.org/F/azure-signalr-dev/api/v3/index.json
<PackageReference Include="Microsoft.Azure.SignalR.Serverless.Protocols" Version="1.3.0" />
Copy to clipboard
source https://www.myget.org/F/azure-signalr-dev/api/v3/index.json
nuget Microsoft.Azure.SignalR.Serverless.Protocols ~> 1.3.0
Copy to clipboard
> choco install Microsoft.Azure.SignalR.Serverless.Protocols --version 1.3.0 --source https://www.myget.org/F/azure-signalr-dev/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "azure-signalr-dev" -SourceLocation "https://www.myget.org/F/azure-signalr-dev/api/v2"
Install-Module -Name "Microsoft.Azure.SignalR.Serverless.Protocols" -RequiredVersion "1.3.0" -Repository "azure-signalr-dev"
Copy to clipboard
Azure Functions Bindings for Azure SignalR Service
Build Status
NuGet Packages
Package Name | Target Framework | NuGet |
---|---|---|
Microsoft.Azure.WebJobs.Extensions.SignalRService | .NET Core App 2.1 .NET Core App 3.1 |
Intro
These bindings allow Azure Functions to integrate with Azure SignalR Service.
Supported scenarios
- Allow clients to serverlessly connect to a SignalR Service hub without requiring an ASP.NET Core backend
- Use Azure Functions (any language supported by V2) to broadcast messages to all clients connected to a SignalR Service hub.
- Use Azure Functions (any language supported by V2) to send messages to a single user, or all the users in a group.
- Use Azure Functions (any language supported by V2) to manage group users like add/remove a single user in a group.
- Example scenarios include: broadcast messages to a SignalR Service hub on HTTP requests and events from Cosmos DB change feed, Event Hub, Event Grid, etc
- Use multiple Azure SignalR Service instances for resiliency and disaster recovery in Azure Functions. See details in Multiple SignalR service endpoint support.
Bindings
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.
Prerequisites
- Azure Functions Core Tools (V2 or V3)
Usage
Create Azure SignalR Service instance
- Create Azure SignalR Service instances in the Azure Portal. Note the connection strings, you'll need them later.
Create Function App with extension
- In a new folder, create a new Azure Functions app.
func init
- Install this Functions extension.
func extensions install -p Microsoft.Azure.WebJobs.Extensions.SignalRService -v 1.0.0
Add application setting for SignalR connection string
- Create an app setting called
AzureSignalRConnectionString
with the SignalR connection string.- On localhost, use
local.settings.json
- In Azure, use App Settings
- On localhost, use
Using the SignalRConnectionInfo input binding
In order for a client to connect to SignalR, it needs to obtain the SignalR Service client hub URL and an access token.
- Create a new function named
negotiate
and use theSignalRConnectionInfo
input binding to obtain the connection information and return it. Take a look at this sample. - Client connects to the
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"
}
Using the SignalR output binding
The SignalR
output binding can be used to broadcast messages to all clients connected a hub. Take a look at this sample:
- HttpTrigger function to send messages
- Simple chat app
- Calls negotiate endpoint to fetch connection information
- Connects to SignalR Service
- Sends messages to HttpTrigger function, which then broadcasts the messages to all clients
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();
};
Contributing
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.
-
.NETStandard 2.0
- MessagePack (>= 1.9.11)
- Microsoft.AspNetCore.SignalR.Protocols.MessagePack (>= 1.1.5)
- Newtonsoft.Json (>= 12.0.1)
- System.Memory (>= 4.5.3)
- .NETStandard 2.0: 2.0.0.0
OwnersJialinXin Yang Zitong Liangying Chenyang Liu |
AuthorsMicrosoft |
Project URLhttps://github.com/Azure/azure-functions-signalrservice-extension |
LicenseMIT |
Info27 total downloads |
3 downloads for version 1.3.0 |
Download (19.25 KB) |
Found on the current feed only |
Package history
Version | Size | Last updated | Downloads | Mirrored? | |||
---|---|---|---|---|---|---|---|
1.10.1-preview1-11168 | 28.79 KB | Fri, 17 May 2024 06:40:24 GMT | 0 | ||||
1.10.1-preview1-11167 | 28.8 KB | Thu, 16 May 2024 09:27:10 GMT | 0 | ||||
1.10.1-preview1-11166 | 28.79 KB | Tue, 14 May 2024 09:21:23 GMT | 0 | ||||
1.10.1-preview1-11156 | 28.8 KB | Fri, 22 Mar 2024 07:58:16 GMT | 1 | ||||
1.10.0 | 28.75 KB | Wed, 31 Jan 2024 09:02:07 GMT | 1 | ||||
1.10.0-preview1-11154 | 28.79 KB | Fri, 01 Mar 2024 04:28:24 GMT | 1 | ||||
1.10.0-preview1-11152 | 28.8 KB | Wed, 21 Feb 2024 09:03:31 GMT | 1 | ||||
1.9.0 | 49.54 KB | Wed, 15 Jun 2022 07:52:21 GMT | 2 | ||||
1.9.0-preview1-10984 | 49.58 KB | Wed, 08 Jun 2022 05:34:00 GMT | 2 | ||||
1.6.0 | 19.25 KB | Mon, 13 Sep 2021 07:29:07 GMT | 3 | ||||
1.5.0 | 19.25 KB | Fri, 16 Jul 2021 05:29:41 GMT | 2 | ||||
1.4.2 | 19.26 KB | Wed, 16 Jun 2021 03:19:44 GMT | 2 | ||||
1.4.1 | 19.28 KB | Tue, 25 May 2021 04:36:44 GMT | 2 | ||||
1.4.0 | 19.28 KB | Wed, 12 May 2021 06:52:47 GMT | 2 | ||||
1.3.0 | 19.25 KB | Fri, 19 Mar 2021 06:01:55 GMT | 3 | ||||
1.2.2 | 22.83 KB | Thu, 10 Dec 2020 04:36:58 GMT | 1 | ||||
1.2.1 | 19.26 KB | Fri, 18 Sep 2020 02:32:56 GMT | 2 | ||||
1.2.0 | 19.26 KB | Mon, 01 Jun 2020 08:28:47 GMT | 2 |