2

I have an AWS Lambda function (API) that returns a result based on some parameters. I want to pass the parameters from my C# controller and consume the returned result as well. How can I call my Lambda API from the C# controller?

3
  • Can you clarify what you mean by "I have an AWS Lambda function (API)"? Did you expose the Lambda function via API Gateway? Or are you wanting to call the function directly? Commented Oct 17, 2016 at 17:38
  • Yes, it is exposed via the API Gateway. I need to invoke the function in my C# controller and use the results returned by the lambda function. Does that clarification help? Commented Oct 17, 2016 at 18:31
  • 1
    If you are calling it via API Gateway then this just becomes a question of how to call an API endpoint over HTTP and process a JSON response, which I'm sure there are tons of tutorials and examples for. The fact that the API is in front of a Lambda function would be irrelevant. Commented Oct 17, 2016 at 18:34

1 Answer 1

1

somethings like this:

        AmazonLambdaClient alc = new AmazonLambdaClient(AWSAccessKey, AWSSecretKey, RegionEndpoint.USEast1);
        Amazon.Lambda.Model.InvokeRequest ir = new Amazon.Lambda.Model.InvokeRequest();
        ir.FunctionName = "arn:YOUR_FUNCTIONS_ARN";
        ir.Payload = SOME_JSON_ARGUMENTS;
        var res = alc.Invoke(ir);
        var yourResult = DESERIALIZE_SOMEHOW(res.Payload);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.