Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 819
Venky Avatar asked Oct 12 '17 16:10

Venky


People also ask

How do you specify app settings for an Azure functions project during local development?

To find the application settings, see Get started in the Azure portal. The Application settings tab maintains settings that are used by your function app. You must select Show values to see the values in the portal. To add a setting in the portal, select New application setting and add the new key-value pair.

What is function json in Azure function?

The function. json file defines the function's trigger, bindings, and other configuration settings. Every function has one and only one trigger. The runtime uses this config file to determine the events to monitor and how to pass data into and return data from a function execution.


1 Answers

Environment.GetEnvironmentVariable("key")

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

like image 64
jayasurya_j Avatar answered Sep 20 '22 03:09

jayasurya_j