Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Reading Environmental variable returns null , always

jalle007's Avatar

jalle007

02 Dec, 2016 12:45 PM

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?

  1. 1 Posted by balexandre on 02 Dec, 2016 08:37 PM

    balexandre's Avatar

    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.

  2. Support Staff 2 Posted by rune on 03 Dec, 2016 03:42 AM

    rune's Avatar

    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

  3. rune closed this discussion on 03 Dec, 2016 03:42 AM.

  4. jalle007 re-opened this discussion on 03 Dec, 2016 11:22 AM

  5. 3 Posted by jalle007 on 03 Dec, 2016 11:22 AM

    jalle007's Avatar

    Hi guys

    I confused Configuration with Environmental variables :)
    Now everything works fine.

    Thank you.

  6. jalle007 closed this discussion on 03 Dec, 2016 11:23 AM.

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