I'm trying to set up SignalR with my Azure system. The setup is fairly standard
When a user starts a time consuming operation from the portal, I want the cloud service to be able to inform all the connected browsers via SignalR that the cloud service is complete.
I thought I could do this using an Azure Function like a SignalR client, that could be triggered to force SignalR to broadcast a message using code in an Azure function like this
HubConnection hub = new HubConnection(*URL OF PORTAL GOES HERE*);
var proxy = hub.CreateHubProxy(*NAME OF HUB GOES HERE*);
await hub.Start();
await proxy.Invoke("Hello"); // Name of default hub method
ASP.NET MVC side, I'm also using Azure Service Bus queues, which seems to be the advice when it comes to scaling. So, in my Startup.cs I've got
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalHost.DependencyResolver.UseServiceBus(@"*SERVICE BUS CONNNECTION STRING GOES HERE*", "blah");
app.MapSignalR();
}
}
Note: In order to get this to work with the latest SignalR I had to use the Microsoft.AspNet.SignalR.ServiceBus3 nuget package otherwise I just got an exception when the UseServiceBus call was made.
Now, it all appears to work. I can call the Azure function from PostMan and sure enough in my browser the signalr call comes through.
However, I'm not sure if this is the right thing to do. Will scaling work in this case or is there a better way of forcing signalr to broadcast messages out?
thanks
You've got the right idea. I am running the same architecture, except I'm using a WebJob instead of an Azure Function. A few points:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.