azureasp.net-corewebsocketazure-web-app-servicesignalr

Using SignalR on Azure App Service running Linux


I'm hosting my ASP.NET Core app - targeting .NET 8 - on Azure App Service running on Linux with a Basic (B1) hosting plan. My app uses SignalR as well.

I don't see a SignalR option under Settings > Configuration. I read somewhere that on Linux, WebSockets are always on but my .NET MAUI app is unable to establish a SignalR connection with my ASP.NET Core app.

Any ideas/suggestions?


Solution

  • The following document makes publishing an ASP.NET Core SignalR app to Azure App Service on Linux clear.

    I want to clarify three important points here:

    1. All Azure App Service hosting plans on Linux, including the free tier support ASP.NET Core SignalR and using Azure SignalR service is NOT required
    2. WebSockets on Azure App Service on Linux seem to be ON by default which may explain why the WebSockets settings doesn't appear under Settings > Configuration if the hosting plan is using Linux as the operating system
    3. One requirement seems to be turning ON the "Session Affinity" setting. In my case it was OFF and I had to turn it ON manually. This may be its default setting

    Here's the Microsoft documentation that provides detailed information on this: https://learn.microsoft.com/en-us/aspnet/core/signalr/publish-to-azure-web-app?view=aspnetcore-8.0#configure-the-app-in-azure-app-service

    Here's another useful document that provides FAQ for App Service on Linux: https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux

    One final point: a few suggested using Azure SignalR service here. The Azure SignalR service is definitely a good choice when needed but one needs to assess that need carefully. From everything I've read so far, the primary benefits of using Azure SignalR service are scalability and management of connections. With that said even the "Basic" hosting plan on Linux seems to support ~50K web sockets per instance. Here's the link to the documentation that provides this info: https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/azure-subscription-service-limits#app-service-limits

    It may not be necessary to jump to Azure SignalR service unless the requirements of the app warrant it.