aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Tracking .NET 8 Support

Open normj opened this issue 3 years ago • 109 comments

Update 2/22/2024

The .NET 8 Lambda runtime has been released.

https://aws.amazon.com/blogs/compute/introducing-the-net-8-runtime-for-aws-lambda/


Completed Tasks

  • Amazon.Lambda.RuntimeSupport, the Lambda runtime client, has been updated for .NET 8 including making the assembly trimmable for .NET 8.
  • Use new .NET 8 APIs in Amazon.Lambda.RuntimeSupport to ensure the .NET runtime understands the amount of memory allocated to the function https://github.com/aws/aws-lambda-dotnet/pull/1578
  • Event packages have been updated for .NET 8 including making the assemblies trimmable for .NET 8.
  • .NET CLI Lambda template updated to have custom runtime templates target .NET 8 and use the provided.al2023 runtime.
  • Amazon.Lambda.Annotations has been updated to support building as an executable assembly. AOT trimming warnings have also been addressed. This allows you target .NET 8 and deploy either as a self contained executable or AOT. A new project template using this feature, more documentation updates and a .NET 8 Lambda build image for AOT will be coming. Checkout James Eastham video on how to use this feature now: https://www.youtube.com/watch?v=kyb16r-Oul0
  • .NET 8 version of the .NET Mock Lambda Test Tool has been released.
  • The .NET 8 OCI image has been published to ECR https://gallery.ecr.aws/lambda/dotnet
    • public.ecr.aws/lambda/dotnet:8
  • .NET 8 build image used for container builds especially Native AOT builds has been released https://gallery.ecr.aws/sam/build-dotnet8
  • Amazon.Lambda.Tools has been updated to use the .NET 8 build image unless override by the --container-image-for-build switch. Amazon.Lambda.Tools will automatically use container builds when building for Native AOT to use matching Amazon Linux 2023 build environment.
  • Amazon.Lambda.AspNetCoreServer and Amazon.Lambda.AspNetCoreServer.Hosting have been updated to target .NET 8 and support Native AOT trimming.
  • Amazon.Lambda.Templates 7.0.0 has been released targeting the .NET Lambda templates to .NET 8.
  • Managed .NET 8 Lambda runtime using the identifier dotnet8 has been released.

normj avatar Nov 14 '23 09:11 normj

Thanks for tracking this. Just to clarify, should we expect all Amazon.Lambda.* packages to be .NET 8 compatible when support is ready?

Also, looking at the completed tasks, it seems a lot has already been done. How much work is remaining?

petro2050 avatar Nov 14 '23 21:11 petro2050

Hi @petro2050

I avoided making a list of what needs to be done because that might imply it is a finite list and as we know with software as we go through things new things and ideas pop up. The long poll task is deploying the managed runtime which requires a lot of operational tasks to make sure everything is in place so it can be well monitored and supported.

From the Amazon.Lambda.* perspective most everything has been verified for .NET 8. The outstanding libraries that still need to be verified is the ASP.NET Core bridge library Amazon.Lambda.AspNetCoreServer and our Amazon.Lambda.Annotations library. We are also working with the SAM team that produce the build container images to get a .NET 8 container image released. That will using Native AOT with .NET 8 a lot easier.

normj avatar Nov 14 '23 21:11 normj

@normj we appreciate that you are on top of this, as some IDE developers are significantly behind the eight ball on support.

Simonl9l avatar Nov 15 '23 03:11 Simonl9l

Updated descriptions with some info on getting started now without managed runtime.

normj avatar Nov 16 '23 20:11 normj

Thank you for the information and the updates, @normj! We are really looking forward to this and appreciate it!

skirk-mpr avatar Nov 17 '23 18:11 skirk-mpr

For projects currently deployed "as-is" on the AWS::Serverless::Function 6.x runtime should we be planning on adding the custom runtime or will 8 also be available without the additional container/image/build setup? Thanks!

jakenuts avatar Nov 21 '23 22:11 jakenuts

@jakenuts Using custom runtimes is a way to use .NET 8 in Lambda today. Eventually we will be releasing a new managed runtime for .NET 8. That means your AWS::Serverless::Function resources could target a dotnet8 runtime when it is released. Unfortunately I can't give a timeframe when the new managed runtime will be available other then it is coming.

normj avatar Nov 22 '23 00:11 normj

@normj & @jakenuts - with .net 7.0 we found that building <SelfContained>True</SelfContained> works fine when deployed with a dotnet6 lambda runtime - the the native runtime is ignored - given that the self-contained is used.

One guesses that will continue work for .net 8.0 again with dotnet6 runtime and hopefully dotnet8?

Albeit we're keen to try with the new al 2023 image as we'd otherwise get a very bizarre runtime issue with deploying a container build on .Net 7.0 on the older al2 image. Fingers crossed this is resolved as @normj was unable to reproduce it.

To us the big value add of this is new runtime is support for Arm64 (with AoT) lambdas and the lower cost!

Simonl9l avatar Nov 22 '23 01:11 Simonl9l

Does it mean that we can do Native AOT builds for .NET8 managed runtime (with PublishAot=true)?

Illivion avatar Nov 22 '23 13:11 Illivion

@Illivion you can indeed, to reshare Norm's update from the description I have a video on YouTube :)

https://www.youtube.com/watch?v=kyb16r-Oul0

jeastham1993 avatar Nov 22 '23 19:11 jeastham1993

@jeastham1993 it looks like that video is using a custom runtime. To clarify - will it be possible to use Native AOT with the managed runtime once it's released, or will we still need to use a custom runtime for that?

DillonN-build avatar Nov 23 '23 16:11 DillonN-build

@DillonN-build yep, you will run be able to native AOT with the managed runtime. Native AOT compiled apps can run anywhere, and once the managed runtime is out we will release some guidance for using both custom runtimes and managed runtimes.

With the .NET 6 managed runtime, you can already use an executable assembly, and this is how native AOT works. We are just working out the finder details but as I said, on release we will provide guidance on how to do that.

jeastham1993 avatar Nov 23 '23 17:11 jeastham1993

sorry all of this is a bit confusing I have image basically the latest with vs 2022 17.8.1 which from with the release of .net 8

my confusion come from.... I want to create a SQS function, but the template still defaults to .net6 neverminded .net7 and well now it should really be .net8.

this discussion/issue, is that about adding the supported or is it already supported and i can simply change it to .net7/8 this is for SQS

Seabizkit avatar Nov 27 '23 15:11 Seabizkit

@jeastham1993 Any indication James as to when this feature will be supported and the managed runtime will be GA?

alexander-manley avatar Nov 29 '23 02:11 alexander-manley

@alexander-manley We are working hard on getting the .NET 8 managed runtime out but we can't give an ETA. There is a lot of coordination across many teams with competing priorities so things are very fluid.

normj avatar Nov 29 '23 06:11 normj

https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-future

This page says the indicative target launch is January 2024.

jecc1982 avatar Nov 29 '23 09:11 jecc1982

If anyone is interested, please try the preview version of the .NET 8 OCI image from ECR and let us know any feedback you have. Thanks!

https://gallery.ecr.aws/lambda/dotnet

public.ecr.aws/lambda/dotnet:8-preview.2023.12.14.16

Using an AWS base image for .NET

Beau-Gosse-dev avatar Dec 14 '23 18:12 Beau-Gosse-dev

The company I work for has a use case that requires being able to install java (java-17-amazon-corretto-headless and a few other supporting packages) into the runtime image. In .NET 7, they used yum to accomplish this. Is there a way to support this use case in the new .net 8 images which don't appear to have yum in them any more?

farmergreg avatar Dec 15 '23 20:12 farmergreg

@farmergreg yum has been replaced with the lighter weight microdnf in the runtime image. I just tested and the command dnf install java-17-amazon-corretto-headless works to find and install the package. You should generally be able to replace yum with dnf (or microdnf which is what is really running)

Beau-Gosse-dev avatar Dec 15 '23 21:12 Beau-Gosse-dev

@Beau-Gosse-dev thank you for the suggestion! I tried it, and it doesn't quite work for me in our Dockerfile. Here's the error I get:

[dotnet-8-runtime-aws-lambda 2/4] RUN dnf install java-17-amazon-corretto-headless: 0.778 Downloading metadata... 1.788 error: failed to remove /var/cache/yum/metadata/amazonlinux-2023-x86_64/repodata

The Dockerfile:

FROM public.ecr.aws/lambda/dotnet:8-preview.2023.12.14.16 AS dotnet-8-runtime-aws-lambda
RUN dnf install -y java-17-amazon-corretto-headless

farmergreg avatar Dec 15 '23 21:12 farmergreg