如何从我的EC2实例调用AWS Lambda函数? [英] How can I invoke an AWS Lambda function from my EC2 instance?

查看:602
本文介绍了如何从我的EC2实例调用AWS Lambda函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个lambda函数来接管我们的Web应用程序中的一些多线程代码。现在,我希望从ASP.NET控制器手动调用lambda函数,然后将该函数的返回值传递回最终用户。

I wrote a lambda function to take over some of the multithreaded code in our web app. Now, I'm looking to manually invoke the lambda function from an ASP.NET controller and then pass the function's return value back to the end-user.

我曾考虑过使用AWS SQS调用该函数,但我丝毫不知道如何获取返回函数的返回值(该值通过<$ c传回) $ c> context.succeed(returnData); )。有任何想法吗?

I thought about using AWS SQS to invoke the function but I haven't the slightest idea how to grab the return function's return value (the value passed back with context.succeed(returnData);). Any ideas?

推荐答案

AWS Lambda现在支持同步( RequestResponse)调用。对于.NET,相关文档为这里。这将返回一个 InvokeResponse ,其 Payload 属性是函数返回的值,即传递给 context.succeed()

AWS Lambda now supports synchronous ("RequestResponse") invocations. For .NET, the relevant documentation is here. This will return a InvokeResponse whose Payload property is what is returned by the function -- that is, passed to context.succeed().

这篇关于如何从我的EC2实例调用AWS Lambda函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆