Amazon AWS C#Lambda代码管道

Amazon AWS C#Lambda代码管道,c#,.net-core,aws-lambda,aws-codepipeline,C#,.net Core,Aws Lambda,Aws Codepipeline,使用AmazonLambda函数模板编写了一个.NETCore2WebAPI应用程序。用邮递员写了一些测试电话。当.NET核心代码在本地运行时,一切正常。将.NET核心代码上载到Lambda函数,修改了postman以调用该URL。只要.NET代码在Lambda函数中运行,就可以正常工作——使用Postman在本地调用 现在的需求是在Lambda函数中调用.NET核心代码-从aws codepipline。不能让它工作 当Postman调用lambda函数时,我在cloudwatch日志中看到:

使用AmazonLambda函数模板编写了一个.NETCore2WebAPI应用程序。用邮递员写了一些测试电话。当.NET核心代码在本地运行时,一切正常。将.NET核心代码上载到Lambda函数,修改了postman以调用该URL。只要.NET代码在Lambda函数中运行,就可以正常工作——使用Postman在本地调用

现在的需求是在Lambda函数中调用.NET核心代码-从aws codepipline。不能让它工作

当Postman调用lambda函数时,我在cloudwatch日志中看到:

Lambda Deserialize Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest:
{
    "resource": "/{proxy+}",
    "path": "/api/Rds/InstanceStatus",
    "httpMethod": "GET",
Lambda Deserialize Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest:
{
    "CodePipeline.job": {
        "id": "379d05fe-ec03-4ec9-8bce-59f31901aeb8",
        "accountId": "109319094079",
        "data": {
            "actionConfiguration": {
                "configuration": {
                    "FunctionName": "NexuIntRestServerless2-AspNetCoreFunction-T8Q5XCCN0FIC",
                    "UserParameters": "{\"resource\":\"/{proxy+}\",\"path\":\"/api/Rds/InstanceStatus\",\"httpMethod\":\"GET\"}"
                }
            },
这个电话有效! 我的.NET核心代码记录了以下内容

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Body = null

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.HttpMethod = GET

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Path = /api/Rds/InstanceStatus

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Resource = /{proxy+}
注意-您可以看到,在调用我的.NET核心代码之前,正在填充lambdaintrypoint对象

当我尝试从codepipeline中复制相同的调用时,我在cloudwatch日志中看到:

Lambda Deserialize Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest:
{
    "resource": "/{proxy+}",
    "path": "/api/Rds/InstanceStatus",
    "httpMethod": "GET",
Lambda Deserialize Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest:
{
    "CodePipeline.job": {
        "id": "379d05fe-ec03-4ec9-8bce-59f31901aeb8",
        "accountId": "109319094079",
        "data": {
            "actionConfiguration": {
                "configuration": {
                    "FunctionName": "NexuIntRestServerless2-AspNetCoreFunction-T8Q5XCCN0FIC",
                    "UserParameters": "{\"resource\":\"/{proxy+}\",\"path\":\"/api/Rds/InstanceStatus\",\"httpMethod\":\"GET\"}"
                }
            },
我尝试在codepipeline用户参数中重现参数。但是,我的.NET核心代码日志记录如下所示:

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Body = null

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.HttpMethod = null

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Path = null

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.Resource = null

LOG_LEVEL_TRACE,Nexus.Rds.Restore.dll,1.0.0.0,Nexus.Rds.Restore.LambdaEntryPoint,FunctionHandlerAsync,APIGatewayProxyRequest.RequestContext = null
注意:lambdaintrypoint现在为null,并引发异常-我假设是因为.NET core不知道如何路由调用:

One or more errors occurred. (Object reference not set to an instance of an object.): AggregateException
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at lambda_method(Closure , Stream , Stream , LambdaContextInternal )

at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayProxyRequest apiGatewayRequest, ILambdaContext lambdaContext)
at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<FunctionHandlerAsync>d__13.MoveNext()
发生了一个或多个错误。(对象引用未设置为对象的实例。):AggregateException
位于System.Threading.Tasks.Task`1.GetResultCore(布尔waitCompletionNotification)
在lambda_方法下(闭包、流、流、LambdaContenternal)
在Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(调用功能、APIGatewayProxyRequest apiGatewayRequest、ILambdaContext LambdContext)
在Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.d_u13.MoveNext()中
关于如何从Codepipeline中调用Lambda函数,有什么想法吗


谢谢

通过postman调用函数时,您似乎正在使用API网关

当从CodePipeline调用时,来自API网关的调用将具有不同的函数输入,因为来自API网关的输入表示HTTP请求而不是CodePipeline作业

需要设计Lambda函数来处理代码管道作业的输入


有关于此作业的格式以及如何使用它的文档,然后在此处将结果报告回CodePipeline:

不是.net核心应用程序的入口点-->公共覆盖任务函数HandlerAsync(APIGatewayProxyRequest请求,ILambdaContext lambdaContext)似乎codepipeline必须像API网关一样填充APIGatewayProxyRequest对象。我在.net核心应用程序中添加了这么多日志记录的原因是-我找不到codepipeline在哪里传递用户参数。如果我可以在函数handlerAsync()中获取用户参数-我可以在.net核心应用程序中执行自己的路由