Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get authenticated user id from negotiate endpoint to use in Azure Function having Service bus input trigger binding and Azure SignalR Service Output binding #1688

Closed
Chays21 opened this issue Sep 24, 2022 · 4 comments

Comments

@Chays21
Copy link

Chays21 commented Sep 24, 2022

can you help with below questions, I am looking for some guidance

  1. question1
  2. When to use this SDK if I could already follow the traditional model (Azure function bindings) of creating negotiate, other functions to send messages to clients.

Originally posted by @Chays21 in #1640 (comment)

@Chays21 Chays21 changed the title How to get authenticated user id to use in Azure Function having Service bus input trigger binding and Azure SignalR Service Output binding How to get authenticated user id from negotiate endpoint to use in Azure Function having Service bus input trigger binding and Azure SignalR Service Output binding Sep 24, 2022
@JialinXin
Copy link
Contributor

Whom(user-id) do you want to send to in the function?

  1. Service bus message trigger user -> you may attach the user-id part of the message or from service bus trigger properties(see here).
  2. A list of users that you've some flags to filter -> the authenticated user list need to be cached somehow(in storage or some places) during negotiation function so when in the message function you can find required user-ids.

@JialinXin
Copy link
Contributor

About Q2, management SDK provides similar functionality comparing with function bindings. Management SDK is a lightweight server that can be hosted in app service/functions. I think you can choose either one to work with.

Basically for output bindings, they both works on the REST API(transient mode). The benefit of management SDK is that it provides better returns than output bindings. For example, if you need to call CheckUserExistence, then suggest to use Management SDK in the function.

And for input bindings, management SDK helps less on reading the request.

  • If the trigger is a service bus message, work with ServiceBusTrigger, alternatively HttpTrigger.
  • If the trigger is a client message on websocket, work with SignalRTrigger, alternatively HttpTrigger.
  • If the trigger is a function exposed API call, work with HttpTrigger.

@Y-Sindo
Copy link
Member

Y-Sindo commented Sep 26, 2022

In reply to #1640 (comment):

How do I know what all function bindings are available with SDK to use? are there any limitations?
I am not sure if I understand your first question. Do you mean that you want to find all the functionalities/features provided by the management SDK? You can see this doc https://github.com/Azure/azure-signalr/blob/dev/docs/management-sdk-guide.md for more details.

I can not figure out the what `names of bindings are there to use? Can you list down the names of bindings that can be used from sdk.

You can find docs of Azure SignalR bindings here. There are also some bindings not listed there, which are for multiple endpoint cases. You can find those specific bindings here

This is not true. ASP.NET Core SignalR refers to the server-side technique you're using. For the client side, you could choose the proper JS library according to your server-side technique. For JS client, you should use @microsoft/signalr library.
ASP.NET Core SignalR JS client
Differences between ASP.NET SignalR and ASP.NET Core SignalR

but I see the below note, here https://github.com/Azure/azure-signalr/blob/dev/docs/management-sdk-guide.md.

Azure SignalR Service Management SDK
NOTE
Azure SignalR Service only supports this SDK for ASP.NET CORE SignalR clients.

This means I can only use this SDK to manage asp.net core signalr clients from my server side code not the reactjs signalr clients. is this understanding correct? other way the question is can I use this SDK to implement negotiate, processupdate functions instead of Azure function bindings to work with ReactJs signalr client?

"Azure SignalR Service only supports this SDK for ASP.NET CORE SignalR clients." This sentence is a little bit confusing. It still means the SignalR client whose server-side technique is ASP.NET Core SignalR. You can use this SDK instead of Azure function bindings to work with ReactJS client. Will improve the doc.

Y-Sindo added a commit that referenced this issue Sep 26, 2022
Improve a confusing statement.
#1688
@Chays21
Copy link
Author

Chays21 commented Sep 26, 2022

@Y-Sindo

Thanks a lot for your clarification, patience and considering updating the guide to clear the confusion.

Y-Sindo added a commit that referenced this issue Sep 27, 2022
Improve a confusing statement. The original statement can also be interpreted as this SDK only supports SignalR clients based on ASP.NET Core C#, which confuses users. #1688
@Chays21 Chays21 closed this as completed Oct 8, 2022
JialinXin added a commit that referenced this issue Nov 8, 2022
* Update Actions to use dotnet build (#1663)

* Update windows.yml

* Add configurable options (#1654)

* Update CI to enable net7.0 preview builds (#1677)

* Support net7.0

* update osx/ubuntu.

* revert common package upgrade.

* update build-source guide and revert net7.0 in src.

* Add OrTimeout()

* Fix build warnings and add net6 samples (#1676)

* Fix build warning

* Update docs

* Fix build failure

* Fix test failure

* Fix vlunerability issue (#1678)

* Fix vlunerability issue

* fix filters

* fix filters

* Update use-signalr-service.md (#1683)

* Change emulator to net6.0 (#1682)

* Change emulator to net6.0

* Fix test

* Add filter property...... (#1686)

* Add filter

* Add multiPayload case

* Adding comments

* Update management-sdk-guide.md (#1689)

Improve a confusing statement. The original statement can also be interpreted as this SDK only supports SignalR clients based on ASP.NET Core C#, which confuses users. #1688

* Expose InstanceId in ClientConnectionContext (#1692)

* Fix `HubConnectionContext.UserIdentifier` is null when negotiation with Management SDK (#1691)

When clients negotiatie with Management SDK and connect to SignalR server, IUserIdProvider might not work as the user ID is set directly in the Management SDK.

To make HubConnectionContext.UserIdentifier have the valid value in this case, we should set it before the server accesses it. HubLifetimeManager{THub}.OnConnectedAsync(HubConnectionContext) is the only chance we can set the value. However, we cannot access the Constants.ClaimType.UserId as ASRS system claims are trimmed there. HubConnectionContext.Features is the place where we can store the user Id.

The following code is the injection point.
https://github.com/dotnet/aspnetcore/blob/v6.0.9/src/SignalR/server/Core/src/HubConnectionHandler.cs#L132-L141

Fixes #1679

* Add ClientInvocationManager (#1684)

* add ClientInvocationManager

* update CallerClientResultsManager (#1697)

add `TryCompleteResult` for `ErrorCompletionMessage`

* Implement close on client authentication expiration (#1699)

* Add spec for client-invocation. (#1701)

* Add spec for client-invocation.

* minor update direction for ErrorCompletionMessage

* Add client Invocation implementation and UTs (#1687)

* Add client Invocation implementation and UTs

* [ClientInvocation] Fix cleanup in caller case. (#1702)

* Fix cleanup in caller case.

* fix UT.

* Update src/Microsoft.Azure.SignalR.Common/ClientInvocation/IClientInvocationManager.cs

Co-authored-by: Liangying.Wei <lianwei@microsoft.com>

Co-authored-by: Liangying.Wei <lianwei@microsoft.com>

* Add ClientResultSample (#1703)

* Add ClientResultSample

* Move file

* minor update.

* minor update README.

* show server/service ex.message

* Add Broadcast method and update README

* Fix proxy not applied to serverless transient mode (#1708)

Fix #1700

* silent IDE0090 check (#1709)

* reduce retry interval when auth failed (#1451)

* Clean up dependencies. (#1711)

* Update dep to GA version.

* clean up dependencies

* clean management.

* fix test dep.

Co-authored-by: Liangying.Wei <lianwei@microsoft.com>
Co-authored-by: Kevin Guo <105208143+kevinguo-ed@users.noreply.github.com>
Co-authored-by: yzt <zityang@microsoft.com>
Co-authored-by: Eric Xing <87063252+xingsy97@users.noreply.github.com>
Co-authored-by: Terence Fan <stdrickforce@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants