Search code examples
c#.net-6.0health-checkazure-signalr

How to add Azure SignalR to health checks


I try to add Azure SignalR healt check using nuget package AspNetCore.HealthChecks.SignalR. I use this code

 services.AddHealthChecks()
    .AddSignalRHub(
       Configuration.GetConnectionString("AzureSignalR"),
       name: "Azure SignalR");

but when I run app in healtcheck window I got info

Unhealthy
Invalid URI: The URI scheme is not valid.

My URI scheme: Endpoint=https://xxxx.service.signalr.net;AccessKey=******;Version=1.0;

How should be look like this URI?


Solution

  • The documentation is non-existent but if you take a look at the tests they have written you can see that its expected to be an http endpoint of the Azure SignalR rather than a connection string:

    https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/test/HealthChecks.SignalR.Tests/Functional/SignalRHealthCheckTests.cs

    And under the hood its basically :

        Func<HubConnection> hubConnectionBuilder = () =>
            new HubConnectionBuilder()
                .WithUrl(url)
                .Build();
    

    as you can see here https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/src/HealthChecks.SignalR/DependencyInjection/SignalRHealthCheckBuilderExtensions.cs