Search code examples
azuresignalrazure-signalr

Do I have to use Azure SignalR for a SignalR service deployed to Azure?


I know the question sounds weird, but recent tests have made me doubt about my SignalR implementation.

I have the following in my startup class (other setup omitted to put things simple as possible):

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSignalR().AddAzureSignalR();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHub<BearHub>("/bear");
        });
    }

I have a paid SignalR subscription in my Azure account which is read from my app settings file when I use the .AddAzureSignalR() part. It works fine.

Later, we needed to add some integration tests. For some reason and after several tries, we discovered that our in-memory SignalR test classes, work fine when we remove the AddAzureSignalR() part!! That makes me remember that I have seen SignalR examples long time before that Azure became an option for many companies. This means: Companies were using SignalR just in their normal App services... or I thing so.

So I am not sure what I'm adding when I use AzureSignalR instead of just an App service with SignalR capacities. I go to the Azure SignalR site and it claims some things that are not clear:

You don’t have to provision and maintain servers just because you need real-time features in your solution. SignalR Service is fully managed which makes it easy to add real-time communication functionality to your application. No more worrying about hosting, scalability, load balancing, and such details!

I don't need to maintain servers also with app services. I neither need to worry about hosting, scalability, balancing. Probably the balancing part is the key here as it could be automatically managed in a better way than an app service. But the other points seems like just propaganda

Benefit from everything Azure has to offer! Easily integrate with services such as Azure Functions, Azure Active Directory, Azure Storage, Azure App Service, Azure Analytics, Power BI, IoT, Cognitive Services, Machine Learning, and more.

That's true with just SignalR and app Services. It would not change if I remove the AddAzureSignalR() part.

I am not sure if we are paying for something that is not needed (even if it is not expensive at all)


Solution

  • Azure SignalR Service is quite new compared to other services. SignalR started way back in 2013. So you can use it in your App Service without Azure SignalR Service just fine. We do so ourselves. I would even guess that most Signal R applications are still using their "own" infrastructure, just because they did not migrate (yet).

    MSDN even has an official full sample for doing this.

    Of the mentioned benefits, the SaaS-Solution has two main benefits for me:

    • Decouple SignalR from your other infrastructure
    • Scaling. You have to use a redis backplane if you scale out with an App Service, and this is quite a jump in costs and infrastructure.