什么是 Azure SignalR 服务?What is Azure SignalR Service?

Azure SignalR Service 简化了通过 HTTP 向应用程序添加实时 Web 功能的过程。Azure SignalR Service simplifies the process of adding real-time web functionality to applications over HTTP. 这种实时功能允许服务将内容更新推送到连接的客户端,例如单页 Web 或移动应用程序。This real-time functionality allows the service to push content updates to connected clients, such as a single page web or mobile application. 因此,无需轮询服务器,或提交针对更新的新 HTTP 请求,即可更新客户端。As a result, clients are updated without the need to poll the server, or submit new HTTP requests for updates.

本文简要介绍了 Azure SignalR Service。This article provides an overview of Azure SignalR Service.

Azure SignalR Service 的用途是什么?What is Azure SignalR Service used for?

需要将数据从服务器实时推送到客户端的任何方案都可以使用 Azure SignalR 服务。Any scenario that requires pushing data from server to client in real time, can use Azure SignalR Service.

通常需要轮询服务器的传统实时功能也可以使用 Azure SignalR 服务。Traditional real-time features that often require polling from server, can also use Azure SignalR Service.

Azure SignalR 服务已在各种行业中使用,适用于需要实时内容更新的任何应用类型。Azure SignalR Service has been used in a wide variety of industries, for any application type that requires real-time content updates. 下面是适合使用 Azure SignalR 服务的一些示例:We list some examples that are good to use Azure SignalR Service:

  • 高频率数据更新: 游戏、投票、轮询、竞拍。High frequency data updates: gaming, voting, polling, auction.
  • 仪表板和监视: 公司仪表板、金融市场数据、即时销量更新、多玩家游戏排行榜和 IoT 监视。Dashboards and monitoring: company dashboard, financial market data, instant sales update, multi-player game leader board, and IoT monitoring.
  • 聊天: 实时聊天室、聊天机器人、在线客户支持、实时购物助手、信使、游戏内聊天,等等。Chat: live chat room, chat bot, on-line customer support, real-time shopping assistant, messenger, in-game chat, and so on.
  • 地图实时定位: 物流跟踪、交货状态跟踪、运输状态更新、GPS 应用。Real-time location on map: logistic tracking, delivery status tracking, transportation status updates, GPS apps.
  • 实时定向广告: 个性化的实时推送广告和套餐、交互式广告。Real time targeted ads: personalized real time push ads and offers, interactive ads.
  • 协作式应用: 共同著作、白板应用和团队会议软件。Collaborative apps: coauthoring, whiteboard apps and team meeting software.
  • 推送通知: 社交网络、电子邮件、游戏、行程通知。Push notifications: social network, email, game, travel alert.
  • 实时广播: 实时音频/视频广播、实时字幕、翻译、活动/新闻广播。Real-time broadcasting: live audio/video broadcasting, live captioning, translating, events/news broadcasting.
  • IoT 和互联设备: 实时 IoT 指标、远程控制、实时状态和位置跟踪。IoT and connected devices: real-time IoT metrics, remote control, real-time status, and location tracking.
  • 自动化: 基于上游事件的实时触发器。Automation: real-time trigger from upstream events.

使用 Azure SignalR 服务的优势是什么?What are the benefits using Azure SignalR Service?

基于标准:Standard based:

SignalR 提供用于生成实时 Web 应用程序的多种技术的抽象概念。SignalR provides an abstraction over a number of techniques used for building real-time web applications. WebSocket 是最佳传输,但在其他选项不可用时,则使用“服务器发送事件(SSE)”和“长轮询”等其他技术。WebSockets is the optimal transport, but other techniques like Server-Sent Events (SSE) and Long Polling are used when other options aren't available. 基于服务器和客户端上受支持的功能,SignalR 自动检测并初始化合适的传输。SignalR automatically detects and initializes the appropriate transport based on the features supported on the server and client.

本机 ASP.NET Core 支持:Native ASP.NET Core support:

SignalR 服务通过 ASP.NET Core 和 ASP.NET 提供本机编程体验。SignalR Service provides native programming experience with ASP.NET Core and ASP.NET. 使用 SignalR 服务开发新的 SignalR 应用程序,或者从基于现有 SignalR 的应用程序迁移到 SignalR 服务只需付出少量的精力。Developing new SignalR application with SignalR Service, or migrating from existing SignalR based application to SignalR Service requires minimal efforts. SignalR 服务还支持 ASP.NET Core 的新功能:服务器端 Blazor。SignalR Service also supports ASP.NET Core's new feature, Server-side Blazor.

广泛的客户端支持:Broad client support:

SignalR 服务适用于广泛的客户端,例如 Web 和移动浏览器、桌面应用、移动应用、服务器进程、IoT 设备和游戏控制台。SignalR Service works with a broad range of clients, such as web and mobile browsers, desktop apps, mobile apps, server process, IoT devices, and game consoles. SignalR 服务以不同的语言提供 SDK。SignalR Service offers SDKs in different languages. 除了本机 ASP.NET Core 或 ASP.NET C# SDK 以外,SignalR 服务还提供 JavaScript 客户端 SDK 来支持 Web 客户端和许多 JavaScript 框架。In addition to native ASP.NET Core or ASP.NET C# SDKs, SignalR Service also provides JavaScript client SDK, to enable web clients, and many JavaScript frameworks. Java 客户端 SDK 还支持 Java 应用程序,包括 Android 本机应用。Java client SDK is also supported for Java applications, including Android native apps. SignalR 服务支持 REST API,与 Azure Functions 和事件网格集成后无需服务器。SignalR Service supports REST API, and serverless through integrations with Azure Functions and Event Grid.

处理大规模客户端连接:Handle large-scale client connections:

SignalR 服务是针对大规模实时应用程序设计的。SignalR Service is designed for large-scale real-time applications. SignalR 服务允许多个实例配合工作,扩展到数百万个客户端连接。SignalR Service allows multiple instances to work together to scale to millions of client connections. 该服务还支持多个全局区域,以实现分片、高可用性或灾难恢复目的。The service also supports multiple global regions for sharding, high availability, or disaster recovery purposes.

消除了自承载 SignalR 的负担:Remove the burden to self-host SignalR:

与自承载 SignalR 应用程序相比,改用 SignalR 服务后,无需管理用于处理规模和客户端连接的后端平面。Compared to self-hosted SignalR applications, switching to SignalR Service will remove the need to manage back planes that handle the scales and client connections. 完全托管的服务还简化了 Web 应用程序并节省了托管成本。The fully managed service also simplifies web applications and saves hosting cost. SignalR 服务覆盖全球,提供一流的数据中心和网络,可扩展到数百万个连接,附带 SLA 保障,并且符合 Azure 的所有合规与安全标准。SignalR Service offers global reach and world-class data center and network, scales to millions of connections, guarantees SLA, while providing all the compliance and security at Azure standard.

托管的 Azure SignalR 服务

为不同的消息传送模式提供丰富的 API:Offer rich APIs for different messaging patterns:

SignalR 服务允许服务器将消息发送到特定的连接、所有连接或属于特定用户或已放置在任意组中的连接子集。SignalR Service allows the server to send messages to a particular connection, all connections, or a subset of connections that belong to a specific user, or have been placed in an arbitrary group.

如何使用 Azure SignalR ServiceHow to use Azure SignalR Service

可通过多种不同的方式对 Azure SignalR 服务编程,下面列出了一些示例:There are many different ways to program with Azure SignalR Service, as some of the samples listed here: