Tan En De
Tan En De

Reputation: 361

Azure Function App's ConfigurationManager.AppSettings return nulls

I have created an app setting name under Application settings as circled in red in the following image (myStorageName). enter image description here

It does have value. However, whenever I call the following line in my HttpTrigger function, it returns null.

accountName = ConfigurationManager.AppSettings["myStorageName"];
log.LogInformation(accountName);

I tried to include myStorageName under Manage but I don't think ConfigurationManager.AppSettings is meant to retrieve function keys and host keys under Manage.

enter image description here

Any solution? Thanks.

Upvotes: 0

Views: 333

Answers (1)

Tan En De
Tan En De

Reputation: 361

This solved my problem. "myStorageName" should indeed be stored under Application Settings.

accountName = System.Environment.GetEnvironmentVariable["myStorageName"];
log.LogInformation(accountName);

App setting name is not to be confused with function keys and host keys.

There are two types of keys:

  1. Host keys: These keys are shared by all functions within the function app. When used as an API key, these allow access to any function within the function app.
  2. Function keys: These keys apply only to the specific functions under which they are defined. When used as an API key, these only allow access to that function.

Upvotes: 2

Related Questions