0

I am pretty a new at azure function development and I a not really understand how configuration for azure function, especially for local development I need to set up some parameters at configuration and use them at my code I have appsettings.json and local.settings.json

I added IConfiguration configuration as parameter to constructor to some my class and try to get value by calling _configuration["MyVar"]

but values are always null. (like it not read appsettings.json)

that is the best practice to get/set some parameters values for local test and use them after on azure side.

Arbejdsglæde
  • 13,670
  • 26
  • 78
  • 144

2 Answers2

3

You can set your configuration values in local.settings.json for debugging and in the Function AppSettings in Azure Portal for when it's deployed. If you want to use a custom appsettings file, you need a FunctionStartup class.

You won't be able to configure the trigger bindings in the appsettings file, you'll have to use the Function AppSettings for that. Please see this StackOverflow post for more details.

Connell.O'Donnell
  • 3,603
  • 11
  • 27
  • 61
1

Recommended way to read App settings in Azure functions(in App Service) is:

var value = Environment.GetEnvironmentVariable("your_key_here");

Check out this article for detailed explanation: Azure — Reading application settings in Azure Functions (ASP.NET Core)

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Harshita Singh
  • 4,590
  • 1
  • 10
  • 13