The problem is sometimes the pubsub rest API throws User not found error when trying to add the user to a group.
This sounds like a service bug that the user is not yet completely registered when the connected
event is triggered. Are you using Free tier or Standard tier? Does it happen frequently? It would be appreciated if you could provide a min-repro project/steps.
There is one convenient way to add the connection to a group when /connect
, to leverage the CloudEvents response groups
in the connect
response body: https://github.com/Azure/azure-webpubsub/blob/main/docs/references/protocol-cloudevents.md#success-response-format
The property provides a convenient way for users to add this connection to one or multiple groups. In this way, there is no need to have an additional call to add this connection to some group.