diff --git a/docs/guide/messaging/transports/signalr.md b/docs/guide/messaging/transports/signalr.md
index a78f75bd1..b83f80a10 100644
--- a/docs/guide/messaging/transports/signalr.md
+++ b/docs/guide/messaging/transports/signalr.md
@@ -46,6 +46,26 @@ builder.UseWolverine(opts =>
// for the WolverineHub
o.ClientTimeoutInterval = 10.Seconds();
});
+
+ // Instead of self-hosting, it's also possible to
+ // use Azure SignalR. Only one of the two SignalR
+ // registrations are necessary. Both register the
+ // required services in DI
+ opts.UseAzureSignalR(hub =>
+ {
+ // Optionally configure the SignalR HubOptions
+ // for the WolverineHub
+ hub.ClientTimeoutInterval = 10.Seconds();
+ }, service =>
+ {
+ // And optionally configure the Azure SignalR
+ // options for the connection.
+ service.ApplicationName = "wolverine";
+
+ // You probably want one of these from your
+ // configuration somehow
+ service.ConnectionString = "Endpoint=https://myresource.service.signalr.net;AccessKey=...;Version=1.0;";
+ });
// Using explicit routing to send specific
// messages to SignalR
@@ -59,7 +79,7 @@ builder.UseWolverine(opts =>
});
});
```
-snippet source | anchor
+snippet source | anchor
That handles the Wolverine configuration and the SignalR service registrations, but you will also need to map
@@ -84,7 +104,7 @@ app.MapWolverineSignalRHub("/api/messages");
return await app.RunJasperFxCommands(args);
```
-snippet source | anchor
+snippet source | anchor
## Messages and Serialization
diff --git a/src/Samples/WolverineChat/Program.cs b/src/Samples/WolverineChat/Program.cs
index 366a679ad..e4436dd24 100644
--- a/src/Samples/WolverineChat/Program.cs
+++ b/src/Samples/WolverineChat/Program.cs
@@ -23,6 +23,26 @@
// for the WolverineHub
o.ClientTimeoutInterval = 10.Seconds();
});
+
+ // Instead of self-hosting, it's also possible to
+ // use Azure SignalR. Only one of the two SignalR
+ // registrations are necessary. Both register the
+ // required services in DI
+ opts.UseAzureSignalR(hub =>
+ {
+ // Optionally configure the SignalR HubOptions
+ // for the WolverineHub
+ hub.ClientTimeoutInterval = 10.Seconds();
+ }, service =>
+ {
+ // And optionally configure the Azure SignalR
+ // options for the connection.
+ service.ApplicationName = "wolverine";
+
+ // You probably want one of these from your
+ // configuration somehow
+ service.ConnectionString = "Endpoint=https://myresource.service.signalr.net;AccessKey=...;Version=1.0;";
+ });
// Using explicit routing to send specific
// messages to SignalR
diff --git a/src/Transports/SignalR/Wolverine.SignalR/SignalRWolverineExtensions.cs b/src/Transports/SignalR/Wolverine.SignalR/SignalRWolverineExtensions.cs
index 4c8df8c2f..72c941850 100644
--- a/src/Transports/SignalR/Wolverine.SignalR/SignalRWolverineExtensions.cs
+++ b/src/Transports/SignalR/Wolverine.SignalR/SignalRWolverineExtensions.cs
@@ -69,6 +69,28 @@ public static SignalRListenerConfiguration UseSignalR(this WolverineOptions opti
return new SignalRListenerConfiguration(transport);
}
+ ///
+ /// Adds the WolverineHub to this application for Azure SignalR message processing
+ ///
+ ///
+ /// Optionally configure the SignalR HubOptions for Wolverine
+ /// Optionally configure the Azure SignalR options for Wolverine
+ ///
+ public static SignalRListenerConfiguration UseAzureSignalR(this WolverineOptions options, Action? configureHub = null, Action? configureSignalR = null)
+ {
+ configureHub ??= _ => { };
+ configureSignalR ??= _ => { };
+
+ options.Services.AddSignalR(configureHub).AddAzureSignalR(configureSignalR);
+
+ var transport = options.SignalRTransport();
+
+ options.Services.AddSingleton(s =>
+ s.GetRequiredService().Options.Transports.GetOrCreate());
+
+ return new SignalRListenerConfiguration(transport);
+ }
+
///
/// Syntactical shortcut to register the WolverineHub SignalR Hub for sending
/// messages to this server. Equivalent to MapHub(route).
diff --git a/src/Transports/SignalR/Wolverine.SignalR/Wolverine.SignalR.csproj b/src/Transports/SignalR/Wolverine.SignalR/Wolverine.SignalR.csproj
index af45f34f8..de87ff6b6 100644
--- a/src/Transports/SignalR/Wolverine.SignalR/Wolverine.SignalR.csproj
+++ b/src/Transports/SignalR/Wolverine.SignalR/Wolverine.SignalR.csproj
@@ -17,5 +17,6 @@
+