我有一个在 AWS 中工作的 .Net6 Lambda。最近改成采用AOT using.Net7。我能够将它成功部署到 AWS,但是在调用 Lambda 时出现以下错误:
/var/task/bootstrap: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /var/task/bootstrap)
这是我的函数模板的样子:
Function:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: dotnet7
Properties:
FunctionName: upload-handler
CodeUri: ./packages/upload-handler
Handler: bootstrap
Runtime: provided.al2
Architectures:
- x86_64
这是我的 .csproject 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PublishAot>true</PublishAot>
<AssemblyName>bootstrap</AssemblyName>
<OutputType>Exe</OutputType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<StripSymbols>true</StripSymbols>
<TrimMode>partial</TrimMode>
<AWSProjectType>Lambda</AWSProjectType>
<Version>1.0.0</Version>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.7" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.5" />
<PackageReference Include="AWSSDK.S3" Version="3.7.103.51" />
<PackageReference Include="AWSSDK.SecretsManager" Version="3.7.102.26" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
</Project>
这是我的 docker 文件的主要部分:
FROM mcr.microsoft.com/dotnet/sdk:7.0
# Install NativeAOT build prerequisites
RUN apt-get update && apt-get install -y --no-install-recommends clang zlib1g-dev
COPY ./src/Upload.Handler/*.csproj ./src/Upload.Handler/
COPY ./upload-handler.sln ./
ARG VERSION
RUN dotnet publish ./src/Upload.Handler -r linux-x64 -c Release -o ./out/upload-handler /p:Version=$VERSION
我使用
docker-compose
和 aws cloudformation package
构建和打包,以及 ws cloudformation deploy
部署到 AWS。
有人可以让我知道我在这里缺少什么吗?