title: SignalR .NET Client connecting to Azure SignalR Service in a Blazor .NET Core 3 application
body: <p>I'm trying to make a connection between my ASP.NET Core 3.0 Blazor (server-side) application and the Azure SignalR Service. I'll end up injecting my SignalR client (service) in to a few Blazor components so they'll update my UI/DOM in realtime. </p>
  
  <p>My issue is that I'm receiving the following message when I call my <code>.StartAsync()</code> method on the hub connection:</p>
  
  <blockquote>
    <p>Response status code does not indicate success: 404 (Not Found).</p>
  </blockquote>
  
  <h3>BootstrapSignalRClient.cs</h3>
  
  <p>This file loads my configuration for the SignalR Service including the URL, connection string, key, method name, and hub name. These settings are captured in the static class <code>SignalRServiceConfiguration</code> and used later.</p>
  
  <pre><code>public static class BootstrapSignalRClient
  {
      public static IServiceCollection AddSignalRServiceClient(this IServiceCollection services, IConfiguration configuration)
      {
          SignalRServiceConfiguration signalRServiceConfiguration = new SignalRServiceConfiguration();
          configuration.Bind(nameof(SignalRServiceConfiguration), signalRServiceConfiguration);
  
          services.AddSingleton(signalRServiceConfiguration);
          services.AddSingleton&lt;ISignalRClient, SignalRClient&gt;();
  
          return services;
      }
  }
  </code></pre>
  
  <h3>SignalRServiceConfiguration.cs</h3>
  
  <pre><code>public class SignalRServiceConfiguration
  {
      public string ConnectionString { get; set; }
      public string Url { get; set; }
      public string MethodName { get; set; }
      public string Key { get; set; }
      public string HubName { get; set; }
  }
  </code></pre>
  
  <h3>SignalRClient.cs</h3>
  
  <pre><code>public class SignalRClient : ISignalRClient
  {
      public delegate void ReceiveMessage(string message);
      public event ReceiveMessage ReceiveMessageEvent;
  
      private HubConnection hubConnection;
  
      public SignalRClient(SignalRServiceConfiguration signalRConfig)
      {
          hubConnection = new HubConnectionBuilder()
              .WithUrl(signalRConfig.Url + signalRConfig.HubName)
              .Build();            
      }
  
      public async Task&lt;string&gt; StartListening(string id)
      {
          // Register listener for a specific id
          hubConnection.On&lt;string&gt;(id, (message) =&gt; 
          {
              if (ReceiveMessageEvent != null)
              {
                  ReceiveMessageEvent.Invoke(message);
              }
          });
  
          try
          {
              // Start the SignalR Service connection
              await hubConnection.StartAsync(); //&lt;---I get an exception here
              return hubConnection.State.ToString();
          }
          catch (Exception ex)
          {
              return ex.Message;
          }            
      }
  
      private void ReceiveMessage(string message)
      {
          response = JsonConvert.DeserializeObject&lt;dynamic&gt;(message);
      }
  }
  </code></pre>
  
  <p>I have experience using SignalR with .NET Core where you add it so the <code>Startup.cs</code> file using <code>.AddSignalR().AddAzureSignalR()</code> and map a hub in the app config and doing it this way requires certain 'configuration' parameters to be established (i.e. connection string).</p>
  
  <p>Given my situation, where does <code>HubConnectionBuilder</code> get the connection string or a key to authenticate to the SignalR Service?</p>
  
  <p>Is it possible the 404 message is a result of the missing key/connection string?</p>