I have made an Azure WebJob in c#. I have a web app on Azure, I added my WebJob to my subscription, all good works but in Application Settings I add a new entry, an example:
<add key="MyDesiredKey" value="1234" />
How can I get value of my key into my application when that runs on azure?
I try like this but not working, in this case no need to have that key in my web config no? When webjob run need to get value from Appsettings from my webapp stored on Azure
var keyFromAzureApp = ConfigurationManager.AppSettings["MyDesiredKey"];
How can I get value of my key into my application when that runs on azure?
According to my test if we have no setting on the azure portal, we will get the null value in the Webjob. Please add it on the azure portal, more detail please refer to the screenshot.
After doing that then all of following ways should work
var myDesiredKey = ConfigurationManager.AppSettings["MyDesiredKey"];
var environmentmyDesiredKey = Environment.GetEnvironmentVariable("MyDesiredKey");
var cloudmyDesiredKey = CloudConfigurationManager.GetSetting("MyDesiredKey");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With