3

The following code has been working in .netcoreapp3.1 but it stopped working after migrating the Http-triggered function to .NET 5.0:

public static class AddToGroup
    {
        [Function("addtogroup")]
        public static Task Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "addtogroup/{trnantId}/{userId}")]
            HttpRequestData req,
            string tenantId,
            string userId,
            [SignalR(HubName = "testhub")]
            IAsyncCollector<SignalRGroupAction> signalRGroupActions,
            FunctionContext executionContext)
        {
            return signalRGroupActions.AddAsync(new SignalRGroupAction
            {
                UserId = $"{tenantId}_{userId}",
                GroupName = tenantId,
                Action = GroupAction.Add
            });
        }
    }

Could anybody throw a guidance on an equivalent of this code in .NET 5.0?

1
  • 1
    Sure would be nice if 2 months later there was anything. This comment is made in solidarity of dealing with this genuinely fun time of trying to migrate to 5.0 while also using Azure. Commented May 24, 2021 at 13:40

1 Answer 1

1

As the error from compiler says: "...Attribute 'SignalROutput' is not valid on this declaration type. It is only valid on 'method, property, indexer' declarations....". You should put the [SignalR(HubName = "testhub")] attribute on the method. Here is a sample.

You can also see in the .Net 5 sample that the return type MyMessage has the same structure with the previous SignalRMessage in sample for .NET class library function apps.

Sign up to request clarification or add additional context in comments.

7 Comments

Putting the compile error aside, how users can be added to a signalR messaging group or how to remove a user from the group?
Previously you add a SignalRGroupAction to the IAsyncCollector, now you can just return the SignalRGroupAction from the method.
where is this point documented on Microsoft's documents website? @sindo
none of those documents that you shared are talking about this topic neither clearly nor explicitly. Would you please show me the exact spot in those documents so that one can conclude your answer?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.