I'm developing a azure function locally, with the Storage Emulator and de Storage Explorer opened.
File tree
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
},
"ConnectionStrings": {
"PlantaoEntities": {
"ConnectionString": "CENSORED",
"ProviderName": "System.Data.EntityClient"
}
}
}
But a receives the following message when trying to run the code:
Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than HTTP. You can run 'func azure functionapp fetch-app-settings ' or specify a connection string in local.settings.json
It's was working before a rebuild solution, and if I try func azure functionapp fetch-app-settings <functionAppName>
it try to retrieve the information from the azure portal itself.
The local. settings. json file is where you can define the values for your project in your developer environment. This file must not be added to your source control because it's specific of your own machine.
AzureWebJobsStorage. The name of an application setting that contains the connection string for the Storage account. The AzureWebJobsStorage setting contains the connection string for the Storage account you created with the function app.
I was getting the same error when I was running my Azure Function
in my Visual Studio 2019
.
I had already set the Copy To Output Directory
action to Copy always
and I was still getting the same error. The issue is that the Azure Function local.settings.json
file doesn't support nested json
. You can track this issue here.
I was having values in local.settings.json
as preceding.
{
"IsEncrypted": false,
"Values": {
"Custom": {
"Tickets": {
"Channels": [
"One",
"Two"
]
}
},
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"ServiceBusConnectionString": ""
}
}
As you can see that there is an extra nested json (Custom) object inside Values, that is the reason why I was getting this error. To fix this, I had to add a new configuration file called configuration.json
and add my custom values there.
"Custom": {
"Tickets": {
"Channels": [
"One",
"Two"
]
}
}
The fix is to use either the ConfigurationBuilder
or read that file using File.ReadAllText
. You can also add the entire JSON as a plain string in the local.settings.json
instead of a JSON object.
Hope it helps.
The solution was to right-click on local.settings.json, go to properties, change "Copy to Output directory" from "Do not copy" to "Copy always". Now the CLI picks up the settings when running from within Visual Studio 2017.
https://github.com/Azure/azure-functions-core-tools/issues/223#issuecomment-326225219
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With