How to get group membership of connection in WebPubSubTrigger

Phil Wardlaw 1 Reputation point
2022-05-19T20:19:54.717+00:00

Is it possible to get the group(s) a user is a member of from a WebPubSubTrigger. Example:

[FunctionName("Test")]
public static async Task Test(
   [WebPubSubTrigger("simplechat", WebPubSubEventType.System, "disconnected")] DisconnectedEventRequest request,
   [WebPubSub(Hub = "hub")] IAsyncCollector<WebPubSubAction> actions,
   ILogger log)
{
   string groupOfUser = ???; // How can we determine this from request?
Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
59 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,251 Reputation points Microsoft Employee
    2022-05-20T23:46:41.94+00:00

    @Phil Wardlaw Thank you for your question regarding how to get the group membership via WebPubSubTrigger.

    In our research, this question was difficult to find an answer to, so we reached out directly to the product group. They shared that when the function side receives the disconnected request from the service, the connection is already gone. This event is kind of a post notification and we currently do not support getting user joined group list from the disconnected request or REST APIs.

    We apologize that this is not currently possible, but we do have the attention of the product group as they would like to better understand why you would like to get this information? If you can provide us a little bit of information about your use case, we can share that directly with the product group and advocate for them to consider a feature request. Please note that this is not a guarantee but it would be a great place to start.

    We look forward to your reply.