Azure Functions - No such host is known
I’ve been building a queue reader with Azure Functions recently and ran into an exception that took me a while to fix. Hopefully this will help others short-circuit the process
Here is the flow:
- I’m using Visual Studio Code.
- I have a simple queue triggered function that is bound to an Azure Queue Storage.
- In a PowerShell terminal I start my function.
- The function starts as expected but after a few seconds an exception is thrown.
The exception reads:
An unhandled exception has occurred. Host is shutting down. Microsoft.WindowsAzure.Storage: No such host is known. System.Net.Http: No such host is known. System.Private.CoreLib: No such host is known.
The problem was with my AZURE_STORAGE_CONNECTION_STRING variable. This is where my queue trigger function gets the connection string which it uses to bind to the queue storage.
I set the variable in my settings.local.json file but as you can see in the screenshot above, the Azure Functions runtime notices that I have an Environment Variable with the same name and uses that instead.
Checking the environment variable in the terminal I can see that it’s pointing to a storage account that doesn’t exist!
Updating the environment variable with the correct connection string resolves the exception.