Azure SignalR Service – Start Building

Azure SignalR Service is a fully managed Azure service for web developers to build real-time web application. It uses Server Push method to talk to online clients. This article helps you to know about SignalR and integration with Azure SignalR Service with ASP.NET Core SignalR. Here are the points I will cover in this guide to know about SignalR Service:

Communication Methods

There are two methods to communicate between server and client such as

  • Request-Response: The client sends the request to server to serve the request. Once the request is processed at the server, it sends the response back to client.
  • Server Push: It pushes a resource directly to the client without the client asking for the resource. SignalR uses this method to talk to the clients.
Real Time Communication Transport

Request-response uses hypertext transfer protocol (HTTP). It pulls data from the server (instead of server pushes data down to the client). Unlike request-response, server push uses following transport protocols such as

  • Web Sockets: It supports duplex communication. It opens a channel and allows the messages to flow between server and client.
  • Server-Side Events: It uses event stream and event source method to receive the update from server to client.
  • Forever Frame: It uses a hidden frame to set up the channel to communicate from server to client.
  • Ajax Long Polling: It uses long help HTTP polling method to receive messages from server to client.

SignalR uses these four transport protocols. Furthermore, SignalR follows a fallback mechanism to use a specific transport mechanism in case the transport is not supported. The fallback order can also be specified explicitly.

What is SignalR

SignalR is an open source library to develop the real time ASP.NET Core application. It requires hubs (at server side) to set up a connection for sending single-recipient, grouped or broadcast messages. To use SignalR in an ASP.NET Core application, you can use hubs to invoke the client methods. At the same time, it requires SignalR clients to open the connection, register the methods and invoke the methods defined in the hubs. At this moment, SignalR server can be implemented either in ASP.NET Core web application or ASP.NET web application. The SignalR client could be anything like JavaScript client, Typescript client, Windows Forms client, UWP client, .NET Core Console client etc. In a nutshell, it requires SignalR library at server side as well as client side both.

Supported SignalR Library

In ASP.NET world, we’ve two flavors (ASP.NET Core and ASP.NET Framework) and SignalR supports both. You can choose any library based on your choice of framework.

Why Azure SignalR Service

Azure SignalR Service will manage the underlying infrastructure for new and existing ASP.NET Core SignalR workloads. It supports SignalR server applications developed in ASP.NET Core and not ASP.NET Framework. This article will help you to choose SignalR Service. The sample application showcases the infrastructure benefits of Azure SignalR Service.
Azure SignalR Service also provides a REST based API. This can be further used for the use cases like

  • Registering a client to Hub
  • Sending message to a client
  • Broadcast message to a group or all connected clients etc.

The REST based API doesn’t require any ASP.NET Core Signal web application to develop. It supports most of the features out of the box.

Sample application using SignalR Service

A sample application is created in GitHub. The application requires an Azure SignalR Service to create. You can follow a step-by step article here to create the service. The GitHub link to the sample application is mugh-signalrsvc-demo

The link to the deck which was used in the session, can be downloaded from here