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.
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.