Azure Functions - using appsettings.json

Is it possible to use an appsettings.json file in Azure Functions?

There is documentation for environment variables here..

..however we use Octopus for deployments and would really like to have appsettings version controlled.

We have tried using

  "frameworks": {
    "net46": {
      "dependencies": {
        "Microsoft.Extensions.Configuration": "1.0.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0"

but constantly get

2016-11-23T15:27:03.811 (12,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=

Even being able to supply/update environment variables via Octopus would be sufficient for our needs.

Please advise.

Only environment variables are supported for app settings and connection strings. appsettings.json is not supported.

However, you can use Azure Resource Manager (ARM) Templates to configure the settings for your Function App. Here's a blog post that describe this in more detail.

using appsettings.json + IConfiguration in Function App � Issue , Learn how to configure Azure function app settings. Many configuration options can also be managed by using the Azure CLI. locally, you must maintain local copies of these values in the local.settings.json project file. This article lists the app settings that are available in function apps. There are several ways that you can add, update, and delete function app settings: In the Azure portal. By using the Azure CLI. There are other global configuration options in the host.json file and in the local.settings.json file.

For your needs the answer is YES! Azure Functions can use appsettings.json for your configurations. But there are some ordering sequence that Azure will do when a Function is requested.

1º) Azure will look for that KEYS that you used on .GetEnvironmentVariables("[KEY]") method, through Keys that were configured on Application Settings blade in Azure Functions settings

2º) If Azure wasn't able to find out that configurations through Application Settings keys, then Azure will try looking for after appsettings.json file into your root folder of the Function that you working on.

3º) Finally, if Azure wasn't able to find out this keys either on Application Settings neither on appsettings.json file, then Azure will do the last attempt to find out web.config for looking for into this file appsettings section keys.

For your appreciation, you'll able to find out these configurations by the sample on my github repo: here and here

I hope that these information help you.

Configure function app settings in Azure, Only environment variables are supported for app settings and connection strings . appsettings.json is not supported. However, you can use� I make use of AZURE_FUNCTIONS_ENVIRONMENT, AzureWebJobsScriptRoot & HOME environment variables to achieve the same. public class Startup : FunctionsStartup { public override void Configure(IFunctionsHostBuilder builder) { // Get the path to the folder that has appsettings.json and other files.

According to the changes made to the configuration files, you should only use local.settings.json since the appsettings.json was renamed to local.settings.json

Reference to the change: azure-functions-cli

Azure Functions - using appsettings.json, For local, app settings are defined in the local.settings.json file which is that ConfigurationManager is not available in Azure Functions v2 . As mentioned in my other articles regarding Azure Functions, the Azure Functions project template excludes the local.settings.json file from source control by default. If you open up the .gitignore, there is a line to exclude the local.settings.json file near the top. # Azure Functions localsettings file local.settings.json

In Azure Functions, setting are stored in local.settings.json (create this file if doesn't exist in your solution/ name should be exact as mentioned).

once you add setting file, you have to configure it under your Run() method as mentioned bellow,

When Accessing setting, use below

IConfigurationRoot config;

use below command to publish settings

func azure functionapp publish *YourAppName* --publish-local-settings -i

Azure — Reading application settings in Azure Functions (ASP.NET , ASP.NET Core normally uses a default builder in the application startup, to enable us to work with appsettings.json . In contrast, when using� We know Azure Functions promotes the usage of App Service Settings, however we have apps migrated from ASP.NET Core applications to functions runtime, and to ease those migrations, we setup a configuration class on function startup and read the settings from there, we even handle per-environment settings like in ASP.NET Core with environment suffixes (appsettings.production.json, appsettings.staging.json).

For dependencies you should use/create the project.json inside your function. There you can specify your dependencies. Please check:

For example:

  "frameworks": {
      "dependencies": {
        "Microsoft.ProjectOxford.Face": "1.1.0"

[Configuration in Azure Functions Series, NET Core configuration, with an emphasis on Azure Functions. In this Configuration-settings in appsettings.json are read using the File� Using JSON and User Secrets configuration with Azure Functions. Tagged with serverless, functions, azure, dotnet.

Introduction to .NET Core configuration, Using JSON and User Secrets configuration with Azure Functions. Tagged with serverless, functions, azure, dotnet. Remember to add the ExecutionContext as an injection to your Azure Function. This piece of code fetches the configuration keys and values from Environment Variables, and a local file called “ local.settings.json “. This file is typically added to your Visual Studio Azure Functions project when it was first created.

Using JSON and User Secrets configuration with Azure Functions , json file – you can manually edit the host.json file. Function app settings.png. The Function App settings apply for the Function App itself, while� A functions project directory contains the files host.json and local.settings.json, along with subfolders that contain the code for individual functions. This directory is the equivalent of a function app in Azure. To learn more about the Functions folder structure, see the Azure Functions developers guide.

Azure Function App Settings - Azure Functions, How to access Azure Function App's settings from C#? to access app.config or local.settings.json values in C# regardless of C# ConfigurationBuilder example for Azure Functions v3 runtime using System; using System. NOTE: Updated on 11/28 to reflect new key vault and function capabilities. One of the common questions around building Azure Functions is how to deal with secrets that a function needs.

  • @mathewc - in the new preview tooling for Azure Functions, it auto-creates an appsettings.json file when I create a Functions project. Has something changed since your answer here?
  • That settings file is for local development only and is used by our CLI. There is a blog post here describing that in more detail.
  • @mathewc It would be fantastic if the tooling would auto-ignore that local.settings.json file from the source control provider, if possible. In addition, when you right-click -> publish (to azure) it gets copied up to the file system. Presumably this local file is not actually needed at runtime, if the Environment Variables get injected from AppSettings?
  • That sounds great, but is it only single key/value pairs? Can I have a complex object like I get from ConfigurationBuilder?
  • Yes, You Can! Just put your configuration like this: SectionA:SubSectionA1:SubSectionA11:"YOUR VALUE GOES HERE". On Application Settings Key field. This "BIG" string is a JSON convention. Use appsettings.json is only one way to create your own configuration, not last. You can use Application Settings on your Functions Portal. Another way that you can try is Azure Key Vault.
  • I'm not sure exactly how that works, but I'll fiddle with it. Thanks...
  • Thanks. Looks like just what I needed. Seems like a hack compared to the full-fledged capabilities elsewhere with web/service apps, but given the lightweight approach for functions is great that it looks like it fits the bill. about to test it out.
  • According to Azure-Functions: Can you use web.config restrictions (e.g. IP restriction or basic Auth) Web.config files do not apply to Function Apps and will be ignored. Where did you source that web.config is used?
  • But local.settings.json is already read and accessible from IConfiguration
  • the question is about appsettings.json, not the project.json file, where you specify nuget dependencies
  • You do not specify dependencies in appsettings.json, that is the reason you have project.json. Check:…
  • I understand that, but the original question was about appsettings.json, not about package dependencies - the OP was trying to have his environment settings and connections in a file, not in the Web App Settings in Azure.