Azure Functions 的 SignalR Service 绑定SignalR Service bindings for Azure Functions

此系列文章介绍如何在 Azure Functions 中使用 SignalR 服务绑定进行身份验证,并向连接到 Azure SignalR 服务的客户端发送实时消息。This set of articles explains how to authenticate and send real-time messages to clients connected to Azure SignalR Service by using SignalR Service bindings in Azure Functions. Azure Functions 支持 SignalR 服务的输入和输出绑定。Azure Functions supports input and output bindings for SignalR Service.

操作Action 类型Type
处理来自 SignalR 服务的消息Handle messages from SignalR Service 触发器绑定Trigger binding
返回服务终结点 URL 和访问令牌Return the service endpoint URL and access token 输入绑定Input binding
发送 SignalR 服务消息Send SignalR Service messages 输出绑定Output binding

添加到 Functions 应用Add to your Functions app

Functions 2.x 及更高版本Functions 2.x and higher

使用触发器和绑定需要引用相应的包。Working with the trigger and bindings requires that you reference the appropriate package. NuGet 包用于 .NET 类库,而扩展捆绑包用于其他所有应用程序类型。The NuGet package is used for .NET class libraries while the extension bundle is used for all other application types.

语言Language 添加方式...Add by... 备注Remarks
C#C# 安装 NuGet 包版本 3.xInstalling the NuGet package, version 3.x
C# 脚本、Java、JavaScript、PowerShellC# Script, Java, JavaScript, PowerShell 注册扩展捆绑包Registering the extension bundle 建议将 [Azure Tools 扩展]用于 Visual Studio Code。The Azure Tools extension is recommended to use with Visual Studio Code.
C# 脚本(Azure 门户中仅限联机)C# Script (online-only in Azure portal) 添加绑定Adding a binding 若要更新现有绑定扩展而不必重新发布函数应用,请参阅更新扩展To update existing binding extensions without having to republish your function app, see Update your extensions.

若要详细了解如何配置 SignalR 服务并将其与 Azure Functions 一起使用,请参阅通过 Azure SignalR 服务进行的 Azure Functions 开发和配置For details on how to configure and use SignalR Service and Azure Functions together, refer to Azure Functions development and configuration with Azure SignalR Service.

注释库(仅限 Java)Annotations library (Java only)

若要在 Java 函数中使用 SignalR 服务注释,需将对 azure-functions-java-library-signalr 项目(1.0 或更高版本)的依赖项添加到 pom.xml 文件。To use the SignalR Service annotations in Java functions, you need to add a dependency to the azure-functions-java-library-signalr artifact (version 1.0 or higher) to your pom.xml file.


后续步骤Next steps