Closed agerasko closed 3 weeks ago
Hi @agerasko, I'd suggest you using management SDK to generate the client access token instead of SignalR input binding.
As the latest SignalR worker extensions package already relies on SignalR management SDK, you don't need to refer to it by yourself.
Here is a code snippet to generate client access token:
#pragma warning disable CS0618 // Type or member is obsolete
var serviceManager = new ServiceManagerBuilder()
.WithOptions(o =>
{
o.ConnectionString = "<connection-string>";
})
.Build(); // serviceManager instance can be a global one.
var token = serviceManager.GenerateClientAccessToken(hubName, user);
var clientEndpoint = serviceManager.GetClientEndpoint(hubName);
return new
{
url = endpoint,
accessToken = token
};
The ServiceManagerBuilder.Build
method is obsolete but we don't have plans to remove it, so it's safe to use and more suitable for you if you have many hubs. Here is the management SDK doc for most users who only have a fixed number of hubs: https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-howto-use-management-sdk#negotiation
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
If you are not the original author (agerasko) and believe this issue is not stale, please comment with /bot not-stale
and I will not close it.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
What version of .NET does your existing project use?
.NET 6
What version of .NET are you attempting to target?
.NET 8
Description
Prerequisites:
HttpTrigger
SignalR
input binding to obtain connection info on Negotiation - URL and access tokenI have slightly complex logic to define
UserId
parameter forSignalR
input binding. So, I can't use binding expression semantic:Is it possible to:
Any other ideas?
Class-based model approach is not suitable for me, as there is need to have one function for many hubs.
Project configuration and dependencies
Link to a repository that reproduces the issue
No response