Reputation: 2535
I'm developing an 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 I receive 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 was working before I rebuilt the solution, and if I try func azure functionapp fetch-app-settings <functionAppName>
then it tries to retrieve the information from the Azure Portal itself.
Upvotes: 105
Views: 160073
Reputation: 69968
Creating a new Function App with .NET 8 and Visual Studio 2022 I needed the following values to make it work:
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_INPROC_NET8_ENABLED": "1",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
Upvotes: 0
Reputation: 1
In my case, I do not HAVE a local.settings.json file.
I have [Project] > Properties (folder) > launchSettings.json (file).
In the launchSettings.json file, set: profiles > (project name) > environmentVariables > "AzureWebJobsStorage": "UseDevelopmentStorage=true"
BTW, launchSettings.json file is set to "Do not copy"
Upvotes: 0
Reputation: 3454
Check if your local.settings.json doesn't have an invalid value in it! For me a was missing a backslash, causing invalid character escaping in my connectiong string.
Upvotes: 1
Reputation: 11
Check once if the local.settings.json is in the same level as the azure functions folder. The function expects the value in this way.
For example:
functions
local.settings.json
EventhubTrigger
function.json
local.settings.json
EventhubTrigger
function.json
Upvotes: 0
Reputation: 21719
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.
Or you can add the custom configs under the Values JSON object
as below.
"CustomConfigs:Config1": "",
"CustomConfigs:Config2:Config3": ""
And use a binding in the Startup
file.
builder.Services.AddOptions<CustomConfigs>()
.Configure<IConfiguration>((settings, configuration) =>
{ configuration.GetSection("CustomConfigs").Bind(settings);
});
Just make sure that you clean the solution and build again after the change above.
Upvotes: 97
Reputation: 1575
in my case i had to do this
<None Update="local.settings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
Upvotes: 2
Reputation: 311
Make sure you have local.settings.json, its spelling is correct and cs proj must have:
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Upvotes: 3
Reputation: 1
If the spelling of the file local.settings.json is wrong, Visual Studio wont find it, but report that the values are not provided.
This is worked for me.
Please check the local.settings.json file name is correct.
Upvotes: 0
Reputation: 7189
Have fixed error by switching Copy to Output Directory
property for local.settings.json
file from Copy if newer
to Copy always
.
In my local local.settings.json
file AzureWebJobsStorage
contains actual connection copied from Storage account
-> Security + networking
-> Access keys
-> key1
-> Connection string
Upvotes: 1
Reputation: 9
Update the local setting below
{
"Values":
{
"AzureWebJobsStorage": "DefaultEndpointsProtocol=`connection string of a blob storage`",
"FUNCTIONS_WORKER_RUNTIME": "python"
},
"IsEncrypted": false
}
Sample connection
string=https;AccountName=xxx;AccountKey=xxxxxxx==;EndpointSuffix=core.windows.net
Upvotes: 0
Reputation: 29
I follow this and it works:
Modify your .csproj file to have this:
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
for more information, check this link: https://www.koskila.net/how-to-fix-missing-value-for-azurewebjobsstorage-in-local-settings-json-when-youre-debugging-azure-functions-locally/
Upvotes: 2
Reputation: 5363
I got mine to work by making sure the connection
value ended with _STORAGE
.
function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "blob",
"type": "blobTrigger",
"direction": "in",
"path": "container/{name}",
"connection": "mystorage_STORAGE"
}
]
}
local.settings.json
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=yyy==;",
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=yyy==;",
"mystorage_STORAGE": "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=yyy==;"
},
"ConnectionStrings": {}
}
Upvotes: 0
Reputation: 11
This could also happen if you declare an string array on the settings since it is not supported. I had something like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
"FUNCTIONS_WORKER_RUNTIME": "node",
"AZURE_STORAGE_CONNECTION": "Optional_your_remote_storage_string_in_azure"
"AZURE_STORAGE_CONTAINER_NAME": "optional_remote_container_name",
"AllowedTypesToProcess":
[
"MyType1",
"MyType2",
"MyType3"
]
},
"Host": {
"LocalHttpPort": 7071
}
}
Since arrays are not supported, it failed to load the settings, but the error says "Missing value for AzureWebJobsStorage in local.settings.json"
If you need to have an array of the settings, take a look to this: https://www.titanwolf.org/Network/q/9256d500-5dbc-4375-851d-4d6f13928945/y
Upvotes: 1
Reputation: 49
Another gotcha:
If the spelling of the file local.settings.json
is wrong, Visual Studio wont find it, but report that the values are not provided.
Upvotes: -1
Reputation: 1126
I fixed this issue finally, it is because of your config files like local.settings.json or appsettings.json show any warning messages then it will fail to load the settings.
Upvotes: -1
Reputation: 2103
FYI, you also get this error when the value for "AzureWebJobsStorage"
is effectively empty (""
). You can set it to e.g. "UseDevelopmentStorage=true"
for development.
Be aware, this requires the storage emulator installed locally. See the docs.
Upvotes: 29
Reputation: 91
Solution - Azure Functions Node.js/Typescript (VSCODE)
This solution is for local development. Be aware, this requires the storage emulator installed locally. See the docs.
1.) From your project root, open local.settings.json
and update the AzureWebJobsStorage
value from ""
to UseDevelopmentStorage=true
.
example: "AzureWebJobsStorage": "UseDevelopmentStorage=true",
2.) Restart Function App
Example local.setting.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
"FUNCTIONS_WORKER_RUNTIME": "node",
"AZURE_STORAGE_CONNECTION": "Optional_your_remote_storage_string_in_azure"
"AZURE_STORAGE_CONTAINER_NAME": "optional_remote_container_name"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": false
}
}
Upvotes: 5
Reputation: 396
I know the question is related to Visual Studio, but I could fix the error by doing the following in Visual Studio Code:
For more details see the official documentation for Azurite
Upvotes: 10
Reputation: 659
I just encounter same issue with Intellij Idea (didn't wanted to move on VSCode). I just had to download Azure Core tools depending on my system (Windows, forced by the client -_-) on :
Then edit the launch config, adding in App settings key :
AzureWebJobsStorage
And in App settings value :
UseDevelopmentStorage=true
Have fun.
Upvotes: -1
Reputation: 23234
For me, I was missing a closing quote on one of my values. As soon as I fixed that, everything worked.
Upvotes: 0
Reputation: 311
For me I found this file to be very finicky so I set it back to the way it was created by VS2019 and added my own configuration as has been suggested above.
Upvotes: 0
Reputation: 251
In case any of the above solutions aren't working for people who require nested JSON in their local.settings.json, just flatten the nested objects as so:
This:
"Config": {
"MyCusomValue": "Value"
}
Becomes:
"Config:MyCustomValue": "Value"
Upvotes: 6
Reputation: 4777
Same error appears when your local.settings.json
file has a json error, e.g. to following commas ,,
.
Upvotes: 16
Reputation: 231
Just saw this error on VS2019 and resolved it by reordering the local.settings.json so that the IsEncrypted value was after the "Values"
{
"Values": {
"AzureWebJobsStorage": "removed",
},
"IsEncrypted": false
}
Upvotes: 23
Reputation: 1511
For anyone that may have encountered this and scratched their heads because they didn't have nested JSON and had their <ItemGroup>
values correct, this may help you. Since local.settings.json
is ignored, I had copied one over using the file system, and though Visual Studio for Mac was showing it in the solution explorer it was apparently not picking it up no matter what I changed <CopyToOutputDirectory>
to. After closing and reopening my solution the issue went away.
Upvotes: 5
Reputation: 2535
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
Upvotes: 104