Recently one of our customers was facing issue in web pubsub with function app sample.
They followed the below simple chat sample and it was working fine while running locally.
azure-webpubsub/samples/functions/csharp/simplechat at main · Azure/azure-webpubsub · GitHub
After publishing the code to azure we started to receive below error
On further analyzing we found that there are 2 application settings keys missing in function app which was causing this error.
1. WebPubSubConnectionString : This will be available under your pub sub account -->Settings -->Keys and you can consider either primary or secondary key
2. WebPubSubHub : Name of the hub configured in pub sub account under pub sub -->Settings --> Settings
After adding WebPubSubConnectionString and WebPubSubHub to the function app, issue got resolved.
With the above keys in place application started working
Alternatively, we can also deploy function app using Azure Functions Core Tools (Azure/azure-functions-core-tools: Command line tools for Azure Functions (github.com)), basically does the same thing, updates the Application Settings in Function App using local.settings.json file.
func azure functionapp publish <FUNCIONAPP_NAME> --publish-local-settings
Hope this helps!!!