2

I was trying to access my web.config values in Azure Function, but then I came to know that we have to add config values in appsettings.json.

I made those changes and uploaded appsettings.json at azure function location but no luck. my azure function is not reading the values kept in json file.

Please suggest way forward.

2
  • What is the your Azure function project target framework? .NET Core or something else? Commented Jan 24, 2018 at 14:32
  • 1.0.11490.0 this is my azure function version. Commented Jan 25, 2018 at 12:56

2 Answers 2

1

The file local.settings.json stores app settings, connection strings, and settings for Azure Functions Core Tools. It has the following structure:

{
      "IsEncrypted": false,   
      "Values": {
        "AzureWebJobsStorage": "<connection string>", 
        "AzureWebJobsDashboard": "<connection string>" 
      },
      "Host": {
        "LocalHttpPort": 7071, 
        "CORS": "*" 
      },
      "ConnectionStrings": {
        "SQLConnectionString": "Value"
      }
    }

We could get more info about Local settings file from this document.

These settings can also be read in your code as environment variables. In C#, use System.Environment.GetEnvironmentVariable or ConfigurationManager.AppSettings. In JavaScript, use process.env. Settings specified as a system environment variable take precedence over values in the local.settings.json file.

Sign up to request clarification or add additional context in comments.

2 Comments

Actually as said by @Mikhail appsettings.json gets ignored.
As Mikhail mentioned that you could use the func CLI to publish settings from your local.settings.json func azure functionapp publish azurefunctionname --publish-local-settings.
0

You should configure your Function App via Application settings menu item, see example.

appsettings.json or other config files are ignored.

2 Comments

Yes, agree final option is this only. But this is really time consuming process for me as my config has more than 100 keys.
@SharadG You can use func CLI to publish settings from your local.settings.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.