83

I'm developing a azure function locally, with the Storage Emulator and de Storage Explorer opened.

File tree

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.

1

19 Answers 19

83
Answer recommended by Microsoft Azure

I was getting the same error when I was running my Azure Function in my Visual Studio 2019.

enter image description here

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.

3
  • 3
    Thanks, this was it for me. In my case, I needed arrays, so I formatted my custom values like so: stackoverflow.com/a/34063168/348375, and it worked.
    – joe
    May 8, 2020 at 22:44
  • 1
    Thanks, this was the same thing that happened to me as well :)
    – HariHaran
    Sep 3, 2021 at 10:35
  • This answer has now saved med twice as I forgot about the limitation and had the same problem in a brand new .net 6 function app created with vs2022. I see the issue has been closed as obsolete, not sure why if it is still an issue. Would be much easier if appsetting.json and local.settings.json behaved the same so I didn't have to keep track of stuff like this.
    – Tarostar
    Feb 2, 2022 at 12:28
80

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

6
  • 3
    There is no "Properties"
    – leonheess
    Nov 25, 2019 at 13:11
  • 3
    This is only when you have your project on VS, not vscode with node.
    – makitocode
    Feb 27, 2020 at 14:48
  • 1
    @makitocode what's the solution in vscode with node?
    – Jono Suave
    Sep 10, 2020 at 22:39
  • 1
    @JonoSuave <CopyToOutputDirectory>Always</CopyToOutputDirectory> Oct 13, 2020 at 8:31
  • 3
    @SamiHuutoniemi Where do I add this configuration?
    – mneumann
    Jan 31, 2022 at 9:29
25

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.

15

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
}
3
  • Excellent! The other issues sounds reasonable enough but this solved it! May 28, 2020 at 10:12
  • 1
    WT...... this works. Nothing was wrong in my local.settings.json because it worked with the same content before. Suddenly it stopped working. Tried everything, clean solution, rebuild, removing bin and obj dirs manually, restart laptop... Nothing worked. Now it does !!!
    – Dennis
    Oct 28, 2020 at 16:10
  • I hate that this is a valid answer because it is so stupid that we have to do things like that with MS config files. Order in a flat file for json should never matter. Aug 17, 2022 at 20:54
11

Same error appears when your local.settings.json file has a json error, e.g. to following commas ,,.

6

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"
5

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.

1
  • 1
    Same for me on Windows. Something in visual studio is getting stuck... It's funny that there are so many different issues out there when you search for problems and the azure functions support is so finicky that a simple VS restart is the last thing that came to mind. Thanks! Apr 21, 2020 at 12:18
5

I know the question is related to Visual Studio, but I could fix the error by doing the following in Visual Studio Code:

  1. Install the "Azurite" extension
  2. Press F1 and type Azurite: Start
  3. Debug your Azure Function as usual (by pressing F5)

For more details see the official documentation for Azurite

5

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
  }
}
1

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/

1

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
0

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.

0

For me, I was missing a closing quote on one of my values. As soon as I fixed that, everything worked.

0

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 :

https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash

Then edit the launch config, adding in App settings key :

AzureWebJobsStorage

And in App settings value :

UseDevelopmentStorage=true

Have fun.

0

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.

0

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.

0

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

0

The solution for my case was I selected the wrong Azure function project. Make sure you select the proper startup project.

0

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": {}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.