News

.NET 6 Runtime for AWS Lambda Unveiled

Amazon Web Services recently introduced the .NET 6 runtime for AWS Lambda, which means .NET-centric cloud coders can now do their serverless computing projects with the latest edition of Microsoft's open source developer platform, which debuted almost four months ago.

"You can now use the .NET 6 runtime to build AWS Lambda functions," AWS said in a Feb. 24 blog post. "The new managed runtime supports both x86 and Arm/Graviton2 processors. You can get started with .NET 6 and Lambda using your tool of choice, including Visual Studio 2022 with the AWS Toolkit for Visual Studio, the .NET CLI with the Amazon.Lambda.Tools global tool, and the AWS Serverless Application Model CLI (AWS SAM CLI)."

Amazon has extensive .NET on AWS documentation that provides all kinds of information on how Microsoft's flagship runtime/developer platform can be used in the AWS cloud, including serverless, event-driven computing.

AWS documentation, for example, shows how an old monolithic .NET REST API project was migrated to AWS Lambda, going from this:

Architecture of the Deployed Monolithic Application
Architecture of the Deployed Monolithic Application (source: AWS).

to this:

Architecture of the Deployed Monolithic Application
[Click on image for larger view.] Architecture After Migrating to Lambda (source: AWS).

which results in a hexagonal architecture pattern:

The Hexagonal Architecture Pattern
[Click on image for larger view.] The Hexagonal Architecture Pattern (source: AWS).

AWS .NET 6 support on AWS documentation says: "You can run .NET 6 applications, targeting x86_64 or ARM64 (AWS Graviton2), on AWS Lambda using any of the following options:

  • Managed Runtime - This option uses a .zip file archive for the deployment package.
  • Managed base container image - Pull from the ECR Public Gallery or use .NET 6 container image Blueprint in the AWS Toolkit for Visual Studio.
  • Custom container image - Build a container image with the .NET 6 application packaged inside it. This PowerShell script will build a .NET 6 base container image.
  • Custom runtime - The custom runtime bundles all necessary .NET 6 libraries in the zip file archive that is deployed to Lambda, see this example. For an ARM64 see this example.

In addition to being able to use the latest languages -- C# 10 and F# 6 -- AWS said its serverless developers can now avail themselves of a host of other .NET 6 features including:

  • Improved logging
  • Using source generator for JSON serialization
  • Top-level statements
  • ASP.NET Core minimal APIs

AWS also noted the switch to an open source Lambda runtime client, one of many projects that Amazon has open sourced and placed in the aws/aws-lambda-dotnet GitHub repository over the past few years. Previously, the open source runtime client was used only in certain scenarios, specifically for functions that used Lambda's custom runtime or container-image based support.

"Now you have a consistent and transparent Lambda runtime client experience in all environments whether that is the managed runtime, container images or using the Lambda runtime client for .NET custom runtimes," AWS said. "The switch from the previous runtime client to the open source runtime client is transparent as Lambda functions are migrated to .NET 6."

The post also provides instructions for migrating to .NET 6.

"We are excited to add support for .NET 6 to Lambda," AWS said in conclusion. "It's fast to get started or migrate existing functions to .NET 6, with many new features in .NET 6 to take advantage of. Read the Lambda Developer Guide for more getting started information.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube