简体   繁体   English

无法在 AWS 中运行 .NET6 容器映像 lambda

[英]Unable to run a .NET6 container image in AWS lambda

I am trying to run a .NET6 image in AWS lambda and it is failing with error:我正在尝试在 AWS lambda 中运行 .NET6 图像,但失败并出现错误:

{ "errorMessage": "RequestId: 5aca05- **** Error: Runtime exited without providing a reason", "errorType": "Runtime.ExitError" }* { "errorMessage": "RequestId: 5aca05- **** Error: Runtime exited without provide a reason", "errorType": "Runtime.ExitError" }*

I am unable to understand why it is failing.我不明白为什么它会失败。 I have used the following command to generate the package of do.net: do.net publish --configuration Release --framework.net6.0 --self-contained true --output output --runtime linux-x64我使用以下命令生成 do.net 的 package: do.net publish --configuration Release --framework.net6.0 --self-contained true --output output --runtime linux-x64

Then I am using docker to create the image and updated in ECR.The aws lambda is giving me above error.然后我使用 docker 创建图像并在 ECR 中更新。aws lambda 给我上面的错误。

The Dockerfile is following: Dockerfile 如下:

ARG BRANCH_VERSION=latest
FROM allimages.docker.****.*****.com/*****/***-al2:${BRANCH_VERSION}

COPY output /var/task
COPY entrypoint.sh /var/task
RUN chmod 755 /var/task/entrypoint.sh

ENTRYPOINT ["/var/task/entrypoint.sh"]
CMD ["LambdaAwsCore::LambdaAwsCore.Function::FunctionHandler"]

The base image is a common private image which does not have do.net in it.基础镜像是一个普通的私有镜像,里面没有do.net。 The entrypoint.sh script will include kerberos later but as of now it is just simple. entrypoint.sh 脚本稍后将包含 kerberos,但到目前为止它很简单。

#!/bin/bash
set -e
echo "Startup ${@}"

I have tried several things but it does not work.我尝试了几件事,但没有用。 When I use AWS do.net-6 image then it works but without providing entrypoint.当我使用 AWS do.net-6 图像时,它可以工作但不提供入口点。 I am not sure why when I am adding the entrypoint it does not work.我不确定为什么当我添加入口点时它不起作用。 Please help.请帮忙。 I have never used C# in AWS lambda.我从来没有在 AWS lambda 中使用过 C#。

I managed to resolve the issue.我设法解决了这个问题。 There were few changes that I had to do.我需要做的改变很少。

  1. Since I am using a container image with the entrypoint.因为我正在使用带有入口点的容器图像。 I had to change the code to executable and then instead of using the format of CMD where we have [AssemblyName::Namespace.Class::FunctionHandler], i had to change it to [./AssemblyName].我不得不将代码更改为可执行代码,然后我不得不将其更改为 [./AssemblyName],而不是使用我们有 [AssemblyName::Namespace.Class::FunctionHandler] 的格式 CMD。
  2. Also i added a line to ensure that the handler is called as part of Function.cs(the file have lambda code).我还添加了一行以确保处理程序作为 Function.cs 的一部分被调用(该文件具有 lambda 代码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM