Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: appsettings.json contents is not being loaded? #1085

Closed
jsiegmund opened this issue Jan 4, 2017 · 3 comments
Closed

CLI: appsettings.json contents is not being loaded? #1085

jsiegmund opened this issue Jan 4, 2017 · 3 comments

Comments

@jsiegmund
Copy link

I'm debugging a Bot Service instance, running locally in the functions cli. I downloaded the appsettings.json file from the online instance, which was neatly copied into appsettings.json locally. When I run "func settings", it shows the correct output. Here is the output with a very simple (test) appsettings.json:

E:\Sources\github\bots-test>func settings list
-> Name: AD_CLIENT_ID
Value: *****

But now when I run the function (debug) in VS, and I have this line:

var test = System.Configuration.ConfigurationManager.AppSettings["AD_CLIENT_ID"];

that gives null. This seems so trivial that I'm completely lost on what is happening here. I've used the app settings in other functions before in the exact same way, never had any issues. Also tried decrypting the file first, nothing. So what could I be overlooking?

@paulbatum
Copy link
Member

@jsiegmund As far as I'm aware, the contents of the "appsettings.json" file is not actually loaded into ConfigurationManager.AppSettings. This is somewhat counter-intuitive. I would use the environment variables API. See here for a quick example.

@mathewc
Copy link
Member

mathewc commented Jan 5, 2017

Note: we've recently moved the CLI to another repo Azure/azure-webjobs-sdk#804. This issue should be moved there.

@jsiegmund
Copy link
Author

Confirmed that using the environment variables indeed fixes the issue. The weird thing though is that I've been using the other method for different functions where it seems to work just fine. So that's very counter intuitive indeed. I'll create a more concrete issue on the other side.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants