Closed amolenk closed 3 years ago
Have you included the function keys when setup the event hander? This is required when function app is hosted in Azure. See snapshot below to get the registered key from Function App. Including the key, the event handler url should be like https://{function-app}.azurewebsites.net/runtime/webhooks/webpubsub?code={webpubsub_extension_key}
There's a known issue when authenticated enabled will always return 401. If the function key is not the reason for you case, can you share more information in your scenario? Share a sample is better.
Thanks! Works perfect now that I use the function key. Has this been documented somewhere already? I couldn't find any docs/samples on hosting a Web PubSub function app in Azure.
Sorry that after a few rounds of document refactor, I missed to add it anywhere. Basically it should be mentioned in both Azure Function side similar to this and our documents side. I'll put it in near future. Thanks for the feedbacks!
Hey @JialinXin, it would be really nice to update documentation. I've just spent 2h debugging until I found this.
@anzax , Thanks for adding comments. I'm working on this. BTW, to help improve the noticing entry, would you share some insights about which doc are you use to work with? I'll add some link to it to help navigation.
@JialinXin, I was using this sources of documentation:
I got it working locally with ngrok but it didn't work when I deployed function app as I didn't know there is a need to specify security code in the webhook url. Moreover, Azure Web PubSub service was returning 500 on an attempt to connect to websockets so it was hard to figure out what was wrong.
For short, I'm updating the sample related to event-handler settings for some further introduction. Besides, we need to add a few more in Azure Docs. Keep the issue open until we finished.
https://github.com/Azure/azure-webpubsub/tree/main/samples/functions/js/simplechat
Describe the bug
I'm trying to use Web PubSub in combination with a C# Function App in Azure. When I sent a custom event to the Function App, the abuse protection fails with status code 401.
If I run the Function locally, use ngrok, and change the event handler to the ngrok URL, everything works fine.
To Reproduce
I've created a Function App called
serverlessponies1805
. In the trace logging, I see the following message:I used that URL to set up my event handler.
I then connect succesfully to the Web PubSub service from a client application and send a custom event.
The live trace now shows the following error:
What am I missing here?