Let's say, I have an enterprise application runs on Azure Web App Service. Among 100+ pages, I have 3-5 pages needs to be served real-time. to benefit from real-time capabilities of Azure SignalR Service, I want to make clients land on my SignalR application (which runs on RignalR Service). But I couldn't find any related example-article about it. How can I invoke a Hub method outside of the code? Any other approach to solve my problem is more than welcome. My main concern here is the performance of real-time pages.
-
I don't quite understand your question. Are you looking for how to send a message to the client from somewhere in your app (outside of a Hub)? – Andrew Stanton-Nurse Oct 26 '18 at 16:43
-
@AndrewStanton-Nurse I am actually wondering, How can invoke any push notification from outside of the hub's project. I want to discover this, because I want to benefit from both Azure web app service and Azure SignalR service – ilkerkaran Oct 27 '18 at 14:49
1 Answers
If you have an ASP.NET Core SignalR Server (i.e. you have classes deriving from Hub
in your application), you can't directly send messages to clients via the Azure SignalR Service. You'd have to provide an API in your ASP.NET Core application that does that.
Azure SignalR does also support a "serverless" mode in which you don't have a Hub
on the server at all. In that model, clients connect directly to the service (instead of first connecting to your app) and then you can send messages to those clients using the REST API. This is a relatively new scenario so there isn't a lot of documentation. There are some blog posts and videos online on the subject, but not a lot of documentation.
If you already have an ASP.NET Core app, I'd suggest doing this by adding a REST API to your own application that allows other services in your application to send messages by calling this API. In the implementation of this API, you can use IHubContext<T>
to send the messages.

- 6,274
- 1
- 28
- 20
-
Yes I already have A Net-Core app and I am aware of IHubContext. It seems fancy but my main concern is about performance /cost-efficiency on Azure services. I doubt if Azure web service can handle so many real-time clients as comfy as SignalR service. Do you have any idea about it? – ilkerkaran Oct 30 '18 at 07:37
-
2You are correct that Azure Web Apps have limitations on concurrent real-time clients. If you use Azure SignalR this isn't a problem. You can deploy your app logic (including the SignalR Hubs) to Azure Web Apps and use the Azure SignalR Service to off-load the real-time traffic. This is the recommended way to build a SignalR application on Azure Web Apps (and it's described in the Azure SignalR docs: https://azure.microsoft.com/en-us/services/signalr-service/) – Andrew Stanton-Nurse Oct 30 '18 at 17:51