'Azure Function Python docker container: Unable to find an Azure Storage connection string to use for this binding

I'm having trouble getting my Azure Function (python, timer trigger) to work in a docker container. Outside of the docker container, everything works just fine. But as soon as I start my container, I get an error saying:

fail: Host.Startup[515] A host error has occurred System.InvalidOperationException: Unable to find an Azure Storage connection string to use for this binding.

My connection string is defined in my local.settings.json. I have no clue as to why this isn't working in the docker container, has anyone dealt with this? I appreciate any direction, thank you.

Edit: Just a clarification, this is happening on my local machine. I have not deployed yet.



Solution 1:[1]

As I said before, I defined my connection string in my local.settings.json. I ended up accessing the file system of the container, and verified that my local.settings.json was in fact in there. I ended up adding my connection string as an env variable in my docker file (AzureWebJobsStorage={YOURCONNNECTIONSTRINGHERE}) and got it working. Hopefully this helps someone who comes across this issue.

Solution 2:[2]

we can pass the connection string as an environment variable called AzureWebJobsStorage to the docker run command.

docker run -p 8080:80 -it -e AzureWebJobsStorage="{connection-string}" <docker-id>

Solution 3:[3]

The explanation is in this github issue.

Basically local.settings.json is only used by the local CLI, it's totally ignored by the runtime

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 billythegoat
Solution 2 robert kalappurackal
Solution 3 Emad Alashi