Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 734
billythegoat Avatar asked Mar 10 '20 00:03

billythegoat


People also ask

How do I get Azure storage connection string?

You can find your storage account's connection strings in the Azure portal. Navigate to SETTINGS > Access keys in your storage account's menu blade to see connection strings for both primary and secondary access keys.

How do I change my connection string in Azure?

Under the settings Section, there are Application settings. Application settings have Connections strings section. You can use this feature for your connection string handling in your application. You can then change this connection string via Azure Web interface or via Azure Powershell.

What is AzureWebJobsStorage?

AzureWebJobsStorage. The Azure Functions runtime uses this storage account connection string for normal operation. Some uses of this storage account include key management, timer trigger management, and Event Hubs checkpoints. The storage account must be a general-purpose one that supports blobs, queues, and tables.


2 Answers

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.

like image 72
billythegoat Avatar answered Oct 17 '22 18:10

billythegoat


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>
like image 42
robert kalappurackal Avatar answered Oct 17 '22 17:10

robert kalappurackal