1

I have an Azure Functions project and locally there is a local.settings.json file with this JSON:

"PushFile": {
    "Location": "value",
    "Port": 22
}

And I can get the values like so

_configuration.GetValue<string>("PushFile:Location");
_configuration.GetValue<int>("PushFile:Port");

So all good locally. Within the Azure Function App service I have added an app setting like so

Name: PushFile
Value: {"Location":"value", "Port": 22}

However when I run the function hosted in Azure the values resolve to null.

Is there something I have to enable/turn on within code or azure?

andrewb
  • 2,995
  • 7
  • 54
  • 95
  • 1
    in Azure, you have to configure your keys as, in this case, `PushFile:Location`, with the value of `value`, and another configuration entry with key `PushFile:Port`with the value of `22` – jalepi Jan 26 '21 at 22:52

1 Answers1

1

The comment is correct. In app settings of your azure function, you should define the name as PushFile:Location and PushFile:Port, like below:

enter image description here

Then you can use the following code to read them:

_configuration.GetValue<string>("PushFile:Location");
_configuration.GetValue<int>("PushFile:Port");
Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • The format of parent:childproperty works but I need to access them using environment variables, not _configuration – andrewb Jan 28 '21 at 19:52