You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
services.AddSignalR().AddAzureSignalR("<connection_string>"); connection string not working in Azure Function Dotnet isolated process as mentioned in MS Document for SignalR
#1920
using System.Collections.Generic;
using System.Net;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
namespace FunctionApp7
{
public class Function
{
private readonly ILogger _logger;
public Function(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger("negotiate");
}
[Function("negotiate")]
public async Task<HttpResponseData> Negotiate(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req,
[SignalRConnectionInfoInput(HubName = "serverless")] MyConnectionInfo connectionInfo)
{
_logger.LogInformation($"SignalR Connection URL = '{connectionInfo.Url}'");
var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
response.WriteStringAsync($"Connection URL = '{connectionInfo.Url}'");
return response;
}
}
public class MyConnectionInfo
{
public string Url { get; set; }
public string AccessToken { get; set; }
}
}
Program.cs
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using static System.Net.WebRequestMethods;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddSignalR().AddAzureSignalR("Endpoint = https://xxxxxxxxxservice.signalr.net;AccessKey=VndLYg4tI1xxxxxxxxxxxxxxxxxx=;Version=1.0;");
})
.ConfigureLogging(logging =>
{
logging.Services.Configure<LoggerFilterOptions>(options =>
{
LoggerFilterRule defaultRule = options.Rules.FirstOrDefault(rule => rule.ProviderName
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (defaultRule is not null)
{
options.Rules.Remove(defaultRule);
}
});
})
.Build();
host.Run();
services.AddSignalR().AddAzureSignalR() uses Azure SignalR Service in default mode, which is not working for Azure Functions. To use Azure SignalR in Azure Functions, you should use serverless mode. Will improve the document to point out that.
Description
As mentioned in MS Document using the code in
Program.cs
file throws exceptionExceptions (if any)
error image
To Reproduce
Function.cs
Program.cs
Csproj
If i use connectionstring in local setting it works perfectly fine. But as mentioned document it should also work fine
The text was updated successfully, but these errors were encountered: