调试AWS无服务器lambda函数与DynamoDBEvents在C#
问题描述:
我的工作与从一个DynamoDB触发器触发了一些lambda函数的AWS无服务器应用程序...调试AWS无服务器lambda函数与DynamoDBEvents在C#
输入在DynamoDB表中的新记录基本上当。 ..it触发一个LamdaFunction,它读入DynamoDBEvent参数中新记录的参数,然后执行一些业务逻辑并将数据写入另一个DynamoDBEvents参数。
我该如何调试才能看到如何从DynamoDBEvents参数中获取值?或者我可以用什么策略来实现我想要做的事情?
有没有办法将Visual Studio Test项目中的DynamoDBEvent模拟到本地的所有函数?
public APIGatewayProxyResponse AddUserTask(DynamoDBEvent dynamoEvent, ILambdaContext context)
{
foreach (var record in dynamoEvent.Records)
{
//do stuff with the values from the new record in the dynamoEvent parameter...
}
var returnObj = new { Success = true };
var response = new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,
Body = SerializeObject(returnObj),
Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
};
return response;
}
答
我知道使用AWS Lambda进行调试的主要方式是使用调试输出记录到CloudWatch。 AWS提供C# Logging documentation。
context.Logger.Log("My debug log!");
您可能会尝试将您的记录传递给该记录。
context.Logger.Log(var.EventSourceArn);
可能会打印出来,否则检查文档还有什么可用的。
感谢Udo .....有效......并且日志在CloudWatch中很好地显示! –