5

I have C# code that works to use a local SignalR server to pass messages between WinForms apps.

I want to revise this code to use the Azure SignalR service.

I created the SignalR resource in the Azure Portal.

I have a connection string that looks like this

Endpoint=[endpoint URI here];AccessKey=[guid here];

so I have a connection string and an AccessKey.

How do I allocate a HubConnection from a WinForms/console app (not a .Net core web app) and use a connection string or assign an AccessKey to the connection?

My current (non-Azure) code just does

var myConnection = new HubConnection(theURI);

Thanks,

Adam

MindModel
  • 822
  • 1
  • 10
  • 22

1 Answers1

6

The client code doesn't change when you use SignalR service. The connection string is used at server side (you still need to have a server when using SignalR service, which hosts the hub logic and does authentication). You client code connects to the server first (using the same API) and server will redirect client to connect to service.

Ken Chen
  • 131
  • 2
  • Ken is the Software Engineering Manager at Microsoft for Azure SignalR Service. His answer is, of course, correct. I am posting this comment in hopes that it will save someone else the time I spent on this issue. There are two distinct, non-interoperable versions of SignalR: SignalR for ASP.Net (older) and SignalR for .Net Core (newer). The ASP.Net version does not work with Azure SignalR. So if you write a .Net Core SignalR client, yes, you do not need to modify it to connect to a .Net Core SignalR server, whether or not this server uses Azure SignalR. – MindModel Jun 28 '18 at 14:18
  • However, if you write an ASP.Net SignalR client and server, not aware that the .Net Core version of SignalR exists, then you try to modify this client/server code to work with Azure SignalR, you will fail. In that case, you need to write new client and server classes based on .Net Core SignalR, so you can use Azure SignalR Service. – MindModel Jun 28 '18 at 14:19
  • As of April 2019 Asp.net now supports the Azure SignalR as noted here: https://devblogs.microsoft.com/aspnet/azure-signalr-service-now-supports-asp-net/ – Kaine Jun 08 '19 at 21:15