无法在 lambda 中部署简单的 hello-world:自包含包的问题



我是 aws 和 aws-lambda-cli 的新闻。所以我试图在这篇文章之后制作一个简单的Hello World:http://www.philliphaydon.com/2017/03/15/part1-creating-a-good-old-hello-world-aws-csharp-lambda/。 一开始唯一的区别:我做了$ dotnet new classlib -n HelloWorldLambda而不是$ dotnet new classlib -n HelloWorldLambda -f netcoreapp1.0,因为我不想针对这个版本。

为了编译,我使用这个命令行:dotnet lambda package,然后我将zip上传到我的lambda并运行测试。CloudWatch 日志显示以下行:

"Failed to execute the Lambda function. The dotnet CLI failed to start with the provided deployment package.  Please check CloudWatch logs for this Lambda function to get detailed information about this failure.: LambdaException "
"Failed to run as a self-contained app. If this should be a framework-dependent app, specify the appropriate framework in /var/task/lambda-synchro-qbo.runtimeconfig.json." 
"A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/var/task/'."

我的lambda-synchro-qbo.runtimeconfig.json位于zip的根目录,包含以下内容:

{
"runtimeOptions": {
"tfm": "netstandard2.0"
}
}

我怀疑我的包不是自包含/可移植的,但即使我像这样编译dotnet lambda package --msbuild-parameters "--self-contained"我也有同样的问题。

我错过了什么?

谢谢 阿莫里

我将目标框架更改为.Net Core 3.1,这起到了作用。

我的runtimeconfig.json现在看起来像这样:

{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}

相关内容

最新更新