Closed Niaxor closed 1 month ago
The issue was that I wasn't setting the ANNOTATIONS_HANDLER environment variable when testing with docker, after reviewing the generated Program.cs I realised that this is a runtime requirement else the program will just literally immediately exit with no error.
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
I'm testing dotnet 8 Lambda w/ Native AOT, and when using
GenerateMain=true
it results in a Runtime Exception with no further details when executed. This is reproduce-able with a modified version of the NativeAOTSample.Regression Issue
Expected Behavior
Modifying the NativeAOTSample with
GenerateMain=true
, then deploying the lambda should function normally, and return the ToUpper() result.Current Behavior
When running the lambda function in a docker container -
Sending a post request to this will result in a 502 bad gateway, and the following output in the console for the docker container:
Reproduction Steps
To reproduce, I have modified the NativeAotSample supplied by AWS to use automatic main generation.
dotnet lambda package
will succeed in generating native code without error from this.Then running in a docker container -
docker run --rm -it -e LOG_LEVEL='trace' -v ${pwd}/bin/Release/net8.0/publish:/var/task -p 9000:8080 amazon/aws-lambda-dotnet:8 NativeAOTSample
Possible Solution
No response
Additional Information/Context
Using a static FunctionHandler does not seem to be compatible with
GenerateMain=true
as it then generates code that doesn't compile. It's not clear if this is intended behaviour or not as it is not a handled error.... docker run: /tmp/source/NativeAOTSample/src/NativeAOTSample/obj/Release/net8.0/linux-x64/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.Generator/Function_FunctionHandler_Generated.g.cs(38,20): error CS0176: Member 'Function.FunctionHandler(string, ILambdaContext)' cannot be accessed with an instance reference; qualify it with a type name instead [/tmp/source/NativeAOTSample/src/NativeAOTSample/NativeAOTSample.csproj]
Using an explicit Main function, without
GenerateMain=true
as per the original sample works fine I.e.AWS .NET SDK and/or Package version used
Amazon.Lambda.Annotations (1.5.2) Amazon.Lambda.Core (2.2.0) Amazon.Lambda.RuntimeSupport (1.10.0) Amazon.Lambda.Serialization.SystemTextJson (2.4.1)
Targeted .NET Platform
.NET 8
Operating System and version
Windows 10 + AmazonLinux