Microsoft Azure SignalR Service is currently in Public Preview.
The Azure SignalR Service is an Azure service based on ASP.NET Core SignalR. ASP.NET Core SignalR is an open source library that simplifies the process of adding real-time web functionality to applications over HTTP. This real-time functionality allows the web server to push content updates to connected clients. As a result, clients are updated without the need to poll the server, or submit new HTTP requests for updates.
This article provides an overview of the Azure SignalR Service. If you want to get started, start with the ASP.NET Core quickstart.
What is SignalR Service used for?
There are many application types that require real-time content updates. The following example application types are good candidates for using the Azure SignalR Service:
- Apps that require high frequency updates from the server. Examples are gaming, social networks, voting, auction, maps, and GPS apps.
- Dashboards and monitoring apps. Examples include company dashboards, instant sales updates, or travel alerts.
- Collaborative apps. Whiteboard apps and team meeting software are examples of collaborative apps.
- Apps that require notifications. Social networks, email, chat, games, travel alerts, and many other apps use notifications.
Internally, SignalR is an abstraction over a number of techniques used for building real-time web applications. 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 automatically detects and initializes the appropriate transport based on the features supported on the server and client.
Developing SignalR apps
Currently, there are two versions of SignalR you can use with your web applications: SignalR for ASP.NET, and ASP.NET Core SignalR, which is the newest version. The Azure SignalR Service is an Azure-managed service built on ASP.NET Core SignalR.
ASP.NET Core SignalR is a rewrite of the previous version. As a result, ASP.NET Core SignalR is not backward compatible with the earlier SignalR version. The APIs and behaviors are different. The ASP.NET Core SignalR SDK is .NET Standard so you can still use it with the .NET Framework. However, you must use the new APIs instead of old ones. If you’re using SignalR and want to move to ASP.NET Core SignalR, or Azure SignalR Service, you’ll need to change your code to handle differences in the APIs.
With Azure SignalR Service, the server-side component of ASP.NET Core SignalR is hosted in Azure. However, since the technology is built on top of ASP.NET Core, you have the ability to run your actual web application on multiple platforms (Windows, Linux, and MacOS) while hosting with Azure App Service, IIS, Nginx, Apache, Docker. You can also use self-hosting in your own process.
If the goals for your application include: supporting the latest functionality for updating web clients with real-time content updates, running across multiple platforms (Azure, Windows, Linux, and MacOS), and hosting in different environments, then the best choice could be leveraging the Azure SignalR Service.
Why not deploy SignalR myself?
It is still a valid approach to deploy your own Azure web app supporting ASP.NET Core SignalR as a backend component to your overall web application.
One of the key reasons to use the Azure SignalR Service is simplicity. With Azure SignalR Service, you don’t need to handle problems like performance, scalability, availability. These issues are handled for you with a 99.9% service-level agreement.
Also, WebSockets are typically the perferred technique to support real-time content updates. However, load balancing a large number of persistent WebSocket connections becomes a complicated problem to solve as you scale. Common solutions leverage: DNS load balancing, hardware load balancers, and software load balancing. Azure SignalR Service handles this problem for you.
Another reason may be you have no requirements to actually host a web application at all. The logic of your web application may leverage Serverless computing. For example, maybe your code is only hosted and executed on demand with Azure Functions triggers. This scenario can be tricky because your code only runs on-demand and doesn’t maintain long connections with clients. Azure SignalR Service can handle this situation since the service already manages connections for you.
How does it scale?
It is common to scale SignalR with SQL Server, Azure Service Bus, or Redis Cache. Azure SignalR Service handles the scaling approach for you. The performance and cost is comparable to these approaches without the complexity of dealing with these other services. All you have to do is update the unit count for your service. Each service unit supports up to 1000 client connections.