Reading Environmental variable returns null , always
I was successful with storing EnvVar but have problems reading it.
For some strange reason return value is always null.
App name : ThingTranslatorAPI2
Var: apiKey
I tried calling Environment.GetEnvironmentVariable("apiKey") from Application_Start and then from within ApiController itself but nothing works.
any ideas please?
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by balexandre on 02 Dec, 2016 08:37 PM
Just to make sure, did you read the Environments wiki page?
From there I assume it's just a
var myVar = Configuration.ConfigurationManager.AppSettings["var_name"]
kind'a call...I might be wrong.
Support Staff 2 Posted by rune on 03 Dec, 2016 03:42 AM
Hi,
AppHarbor doesn't currently inject configuration variables in the user environment, so you'd need to set them yourself if you need it -- I've seen a few cases were third party libraries require environment variables to be set, but that's not very common. If you control the code I'd recommend just using the application's AppSettings as balexandre adviced.
Let me know if your use case somehow requires environment variables and I'll be happy to look furher into that!
Best,
Rune
rune closed this discussion on 03 Dec, 2016 03:42 AM.
jalle007 re-opened this discussion on 03 Dec, 2016 11:22 AM
3 Posted by jalle007 on 03 Dec, 2016 11:22 AM
Hi guys
I confused Configuration with Environmental variables :)
Now everything works fine.
Thank you.
jalle007 closed this discussion on 03 Dec, 2016 11:23 AM.