Reputation: 265
I've read a lot of posts on accessing IConfiguration inside Startup like this and I've seen people building their own ConfigurationRoot, but for my simple scenario:
Is it OK to use Environment.GetEnvironmentVariable which meets both of those requirements?
Upvotes: 3
Views: 1664
Reputation: 14088
Update:
Azure Function is based on Web App Sandbox, so it's env var is from Application Settings.
Have a look of Azure Function Basic of Web App Sandbox:
https://learn.microsoft.com/en-us/sandbox/functions-recipes/functions-basics
This is the way to access the env var:
This doc explains the local.settings.json is the app settings when azure function is running on local:
And this explains azure function app settings is in Configuration on azure:
Original Answer:
Yes, it is ok.
Azure Function reads settings from local.settings.json on local and reads settings from Configuration settings on Azure, both of them will be read as env var.
So you can simply use
Environment.GetEnvironmentVariable("yoursettingskey");
Upvotes: 2