Alright, so we have multiple signalR services and what we want to do is when our code is deployed, we want the connection string to be picked from our custom configuration file instead of the function App settings.
This is the negotiate function. See the "SignalRConnectionInfo" attribute.
[FunctionName("negotiate")]
public IActionResult negotiate(
[HttpTrigger(AuthorizationLevel.Function, "post")]
HttpRequest req,
[SignalRConnectionInfo(HubName = HubName, ConnectionStringSetting = **"Cannot pass dynamic connection string here as it requies a constant"**)]
SignalRConnectionInfo connectionInfo )
{
}
we tried adding it in Startup.cs
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
IConfigurationRoot config;
builder.Services.AddSignalR().AddAzureSignalR(config["SignalrConnectionString"]);
}
}
and it does not work this way. as it gives an error
Invalid host services. Microsoft.Azure.WebJobs.Script.WebHost: The following service registrations did not match the expected services: [Invalid] ServiceType: Microsoft.Extensions.Hosting.IHostedService, Lifetime: Singleton, ImplementationType: Microsoft.Azure.SignalR.HeartBeat Value cannot be null. Parameter name: provider
So, is there any other way to use it in the function?