I am a little bit confused on how my console application connects to Azure SignalR Server to receive the notifications that I am sending through my ASP.NET Core Web API application.
In the startup of my API I do what is needed:
services.AddSignalR().AddAzureSignalR();
app.UseAzureSignalR(routes =>
{
routes.MapHub<NotificationHub>("/notifications");
});
AddAzureSignalR() method connects to the Azure SignalR server via my defined connectionstring in my appsettings.
But as I saw in many examples, to get connected with my console application, I need to do the following:
var connectionBuilder = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/notifications")
.Build();
await connectionBuilder.StartAsync();
connectionBuilder.On<string, string>("broadcastNotification", (name, message) =>
{
Console.WriteLine($"Name: {name}, Message: {message}");
});
What are the reasons that my console application connects to the Azure SignalR server through my API and not directly? Security or by design?