Thursday, December 15, 2016

Using environment variables with AWS Lambda & C#

Environment variables are a great new feature that has been added to Lambda functions in AWS. But how do you access them in a C# lambda function? Digging through the context parameter I thought I'd found it @: ILambdaContext.ClientContext.Environment

But it turns out, they are available through the static class System.Environment, e.g:

var variableValue = Environment.GetEnvironmentVariable("nameOfVariable");

....

edit: wow just realised it's been almost two years since my last post.... time to bring this thing back to life :)

9 comments:

  1. Thank you for sharing this. Saved me heaps of time.

    ReplyDelete
  2. Nice one. The advantage of taking them from context is that you can mock the values for unit tests. It's not ideal to have any class tied to another static class.

    ReplyDelete
  3. NICE!!!!!!!!!! Saved me. Regards HueHue

    ReplyDelete
  4. I have read this post. collection of post is a nice one AWS Online Training Bangalore

    ReplyDelete
  5. This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up
    salesforce Online course Bangalore

    ReplyDelete
  6. It's a nice post I was really impressed by reading this Dot NET Online Course Hyderabad

    ReplyDelete
  7. Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles.

    Digital Marketing Training in Chennai

    Digital Marketing Course in Chennai

    ReplyDelete