我终于设法让我的API进入可以将其上传到AWS Lambda的状态,然后每当我尝试使用API网关进行测试时,我都会收到以下错误。
{
"errorType": "AggregateException",
"errorMessage": "One or more errors occurred. (Object reference not set to an instance of an object.)",
"stackTrace": [
"at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)",
"at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)",
"at lambda_method(Closure , Stream , Stream , ContextInfo )"
],
"cause": {
"errorType": "NullReferenceException",
"errorMessage": "Object reference not set to an instance of an object.",
"stackTrace": [
"at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayProxyRequest apiGatewayRequest)",
"at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<FunctionHandlerAsync>d__12.MoveNext()"
]
}
}
代码:
public class LambdaEntryPoint :
Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
{
protected override void Init(IWebHostBuilder builder)
{
try
{
builder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseApiGateway();
}
catch (Exception ex)
{
LambdaLogger.Log("Exception throw in LambdaEntryPoint: " + ex);
}
}
}
我没有从我的Startup或LambdaEntryPoint中记录任何异常。我对AWS很陌生,所以我不确定还有什么要检查。
关于这个的任何想法?
答案 0 :(得分:0)
这可能与AWS的某个人在AWS github repo上与其他人在AWS .NET Lambda集成中解决的问题相同: https://github.com/aws/aws-lambda-dotnet/issues/168