Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking .NET 8 Support #1611

Closed
normj opened this issue Nov 14, 2023 · 109 comments
Closed

Tracking .NET 8 Support #1611

normj opened this issue Nov 14, 2023 · 109 comments

Comments

@normj
Copy link
Member

normj commented Nov 14, 2023

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 Use the new .NET 8 APIs to configure max heap memory size #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 normj added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. Announcement and removed feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
@normj normj pinned this issue Nov 14, 2023
@petro2050
Copy link

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?

@normj
Copy link
Member Author

normj commented Nov 14, 2023

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.

@Simonl9l
Copy link

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

@normj
Copy link
Member Author

normj commented Nov 16, 2023

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

@skirk-mpr
Copy link

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

@jakenuts
Copy link

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!

@normj
Copy link
Member Author

normj commented Nov 22, 2023

@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.

@Simonl9l
Copy link

@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!

@Illivion
Copy link

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

@jeastham1993
Copy link
Contributor

@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

@DillonN-build
Copy link

@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?

@jeastham1993
Copy link
Contributor

@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.

@Seabizkit
Copy link

Seabizkit commented Nov 27, 2023

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

@alexander-manley
Copy link

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

@normj
Copy link
Member Author

normj commented Nov 29, 2023

@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.

@jecc1982
Copy link

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

This page says the indicative target launch is January 2024.

@Beau-Gosse-dev
Copy link
Contributor

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

@farmergreg
Copy link

farmergreg commented Dec 15, 2023

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?

@Beau-Gosse-dev
Copy link
Contributor

@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
Copy link
Contributor

@nibblesnbits Keep an eye on this PR to be released in order to use SAM CLI with .NET 8: aws/aws-sam-cli#6429

@skirk-mpr
Copy link

Thank you @normj and team for all your hard work on this effort!

image

@DennisJansenDev
Copy link

When will the Amazon.CDK.Lib (v2.128.0) be updated? The Amazon.CDK.AWS.Lambda.Runtime still only holds DOTNET_6 as choice, DOTNET_8 is nowhere to be found?

@Dreamescaper
Copy link
Contributor

@DennisJansenDev
You can use new Runtime("dotnet8", RuntimeFamily.DOTNET_CORE) until it's updated.

@DennisJansenDev
Copy link

@DennisJansenDev

You can use new Runtime("dotnet8", RuntimeFamily.DOTNET_CORE) until it's updated.

Aaah perfect! Thank you very much! 😁

@normj
Copy link
Member Author

normj commented Feb 21, 2024

As people have seen .NET 8 is starting to show up. We are not announcing it "released" yet because it takes awhile to get out all of the pieces connected to Lambda runtime.

@Beau-Gosse-dev
Copy link
Contributor

@DennisJansenDev and @Dreamescaper The latest CDK release v2.129.0 now includes dotnet8. Please give it a shot!

@finukan
Copy link

finukan commented Feb 22, 2024

@Beau-Gosse-dev, @normj well done :-)

@PreppyGreen
Copy link

Fantastic news! Well done @normj @Beau-Gosse-dev and everyone involved!

@normj
Copy link
Member Author

normj commented Feb 22, 2024

Release is done! Thanks you all for your patience and looking forward to hearing what you all build with the new .NET 8 Lambda runtime.

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

@michelmob
Copy link

Congratulations @normj and everyone involved. This release will bring a lot of benefits and performance improvements.

@skirk-mpr
Copy link

@normj you are my hero.

@granticini
Copy link

granticini commented Feb 22, 2024 via email

@ckcks12
Copy link

ckcks12 commented Feb 23, 2024

Thank you!
.NET8 AOT on AWS Lambda Managed Runtime
is 40% faster cold start (init duration)
and (looks like a bug or something but) 95% cheaper (billed duration)

image
image
image

Billed Duration.. is it correct? 🤔

@ian-rebuild
Copy link

Will this same GitHub issue track the .NET 8 managed runtime being released to AWS gov cloud?

@ckcks12
Copy link

ckcks12 commented Feb 23, 2024

Why does dotnet lambda package use docker for building?? It's not working on my wsl2 env (such as no csproj found errors, kinda mount or something issue) btw dotnet publish -r linux-x64 works totally fine, though.

@normj
Copy link
Member Author

normj commented Feb 23, 2024

Now that the managed runtime released along with all of the client tooling I'm closing the issue. For any issues or questions feel free to open a separate issue or discussion on the repository.

@ckcks12 That is an awesome plot, thanks for sharing.

dotnet lambda package uses docker for Native AOT by default if it detects you are not running on Amazon Linux. For Native AOT you want to use the same distribution of Linux for build and target runtime. So unless the distribution you are using Amazon Linux under WSL2 it will try to do a container build.

@ian-rebuild I know the Lambda team is rolling out the runtime to gov cloud but I don't have much visibility when that is happening so unfortunately this wouldn't be a good place to track it.

@normj normj closed this as completed Feb 23, 2024
Copy link
Contributor

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.

@slang25
Copy link
Contributor

slang25 commented Feb 23, 2024

I've updated the Lambda Cold Starts benchmark by maxday with the dotnet8 runtime. The NativeAOT numbers are fantastic.

@jeastham1993
Copy link
Contributor

Thanks for doing that @slang25 ❤️🎉

@h4570
Copy link

h4570 commented Feb 24, 2024

If anyone is planning to migrate a dotnet6 managed runtime lambda to dotnet8 with native AOT, I'm adding my notes from today's work.

As a test, I migrated a small project with a stack: Lambda, DynamoDB, S3, SQS, and SNS (forwarding requests to a queue, writing to the database, processing, and notifying upon completion). The migration went relatively smoothly, but I noticed that not all AWS nugets support native AOT yet. Despite this, they can still be used, but they might throw an exception during execution. One of them is DynamoDB - which could be a blocker for many. While executing DynamoDbContext.SaveAsync<>(obj), an exception System.InvalidOperationException: Type System.String is unsupported, it cannot be instantiated is thrown.

This can be fixed in the following, not elegant way: aws/aws-sdk-net#2542 (comment).
Then, information about the rd.xml file needs to be added to the .csproj file:

<ItemGroup>
  <RdXmlFile Include="rd.xml" />
</ItemGroup>

After this fix, I did not notice any other problems with DynamoDbContext.
It seems to me that when it comes to native AOT, we still have to wait a bit - at least for the AWS libraries.

@jeastham1993
Copy link
Contributor

@h4570 moving forward you should use the TrimmerRootAssembly properties in the csproj file instead of using rd.xml. You can find an example in our benchmarking repo.

In the GH issue you've linked you'll see that Beau also mentions the move away from rd.xml.

@simonekstal
Copy link

Any information on when this will be supported for the China region?

@haquex19
Copy link

Any update on govcloud regions? A previous post said this is probably not the right place to track it, but where is the correct place to track updates on govcloud?

@genifycom
Copy link

Any progress on packaging up WASM for DotNet Lambda?

I opened a toolkit issue aws/aws-toolkit-visual-studio#414 but maybe this is a bigger issue with the DotNet 8 managed runtime?

This is to support the "Blazor United" DotNet 8 feature of providing both server side rendered components and WebAssembly components in the same publish.

@normj normj unpinned this issue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests