Search code examples
azureazure-web-app-servicesignalrazure-app-service-envrmntazure-signalr

Unable to read Azure SignalR Connection String from Azure App Service Configuration Application Settings


I am working on an Azure SignalR application and everything is working fine on my local machine when I set the following section in my appsettings.json:

 "Azure": {
    "SignalR": {
      "ConnectionString": "XXXXX"
    }
  }

And then initialize in my startup.cs as follows:

services.AddSignalR().AddAzureSignalR();

However when I create the same environment variable in my Azure App Service using App Service>Configration>ApplicationSettings: enter image description here

My application is unable to start and I get the following application error:

System.ArgumentException: Connection string missing required properties endpoint and accesskey. (Parameter 'connectionString')
   at Microsoft.Azure.SignalR.ConnectionStringParser.Parse(String connectionString)
   at Microsoft.Azure.SignalR.ServiceEndpoint..ctor(String connectionString, EndpointType type, String name)

When I hardcore my connection string onto the AddAzureSignalR() connectionstring parameter and deploy everything works fine.

It would seem that azuresignalR is unable to pickup this environment variable, despite also being able to see it via the Kudo Appsettings page as Azure:SginalR:ConnectionString.


Solution

  • So I asked this same question on the Azure SignalR github page and below was the answer I got:

    EnvironmentVariablesConfigurationProvider automatically replaces __ with : . So when you configures connection string via environment variables, you should use Azure__SignalR__ConnectionString as the key. When you configures it via JSON file, you should use the origin key Azure:SignalR:ConnectionString.

    Once I changed it to the double underscores all worked