0

In my local.settings I have nested settings like this

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "Email:Email": "test",
    "Email:Password": "*******",
  },
}

I am reading the values like this

config.GetValue<string>("Email:Email")

But when I am adding azure settings in azure function app (after deploying) I cannot add : into the name. Any suggestions for it?

mohsinali1317
  • 4,255
  • 9
  • 46
  • 85

1 Answers1

0

One of the workaround you can follow,

When we are creating azure function in local and deploy to azure our localsettings.json file not upload .We need to update them manually by adding it on portal.

In localsettings.json file you have used : which is accepted by local environment. But When deploying we need to use __ instead.

Followed by this MICROSOFT DOCUMENTATION:-

The app setting name like ApplicationInsights:InstrumentationKey needs to be configured in App Service as ApplicationInsights__InstrumentationKey for the key name. In other words, any : should be replaced by __ (double underscore).

Likewise you can set something like below e.g;

"Email__Email": "test",
    "Email__Password": "*******",

For more information please refer this SO THREAD| azure application settings - how to add nested item & Nested object from local.settings.json in Azure function v3 settings .

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15