csharp 致电AWS Lambda

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 致电AWS Lambda相关的知识,希望对你有一定的参考价值。

using Amazon.Lambda;
using Amazon.Lambda.Model;
using Amazon;
using Newtonsoft.Json;

//The access and secret keys are optional, will use your credentials if not provided
AmazonLambdaClient client = new AmazonLambdaClient(
  //"Access Key", 
  //"Secret Key", 
  RegionEndpoint.USEast1);

var input = new Dictionary<string, string>
{
    { "Input1", "Sample" },
    { "Input2", "Sample" }
};

InvokeRequest ir = new InvokeRequest
{
    FunctionName = "FunctionName",
    InvocationType = InvocationType.RequestResponse,
    Payload = JsonConvert.SerializeObject(input)
};

InvokeResponse awsResponse = client.Invoke(ir);
if (awsResponse.HttpStatusCode != System.Net.HttpStatusCode.OK)
{
    throw new Exception(awsResponse.FunctionError);
}

var sr = new StreamReader(awsResponse.Payload);
response.Value = JsonConvert.DeserializeObject<FacilityInfo>(sr.ReadToEnd());

以上是关于csharp 致电AWS Lambda的主要内容,如果未能解决你的问题,请参考以下文章

csharp E10致电BOReader

[AWS Lambda] Scheduling Events with AWS Lambda (a.k.a. Lambda cron jobs)

AWS lambda 和 AWS Lambda@EDGE 有啥区别?

从 AWS API Gateway Web 界面配置 AWS Lambda 时无法选择/查看 Lambda 函数

AWS Lambda 无法调用没有 VPC 的另一个 AWS Lambda - NodeJs

csharp 使用lambda的小组