Read values from local.settings.json in VS 2017 Azure Function development

Venky picture Venky · Oct 12, 2017 · Viewed 32.3k times · Source

I am writing an Azure function in VS 2017. I need to set up a few custom configuration parameters. I added them in local.settings.json under Values.

{
   "IsEncrypted":false,
   "Values" : {
      "CustomUrl" : "www.google.com",
       "Keys": { 
           "Value1":"1",
           "Value2" :"2"
       }
   }
}

Now, ConfigurationManager.AppSettings["CustomUrl"] returns null.

I'm using:

  • .NET Framework 4.7
  • Microsoft.NET.Sdk.Functions 1.0.5
  • System.Configuration.ConfigurationManager 4.4.0
  • Azure.Functions.Cli 1.0.4

Am I missing something?

Answer

jayasurya_j picture jayasurya_j · Sep 7, 2018

Environment.GetEnvironmentVariable("key")

I was able to read values from local.settings.json using the above line of code.