Paul Krill
Editor at Large

AWS Lambda backs .NET 6.NET Lambda capabilities

news
Feb 28, 20222 mins

AWS Lambda users now can write event-driven, serverless functions in the latest version of Microsoft .NET. The .NET 6 Lambda runtime also improves logging and traceability.

empty computer server roomaa044849
Credit: Thinkstock

AWS Lambda functions now can be built with Microsoft’s .NET 6, the latest major version of the software development platform. The introduction of the .NET 6 runtime for AWS Lambda enables new .NET Lambda capabilities that improve performance and diagnostics and support new coding patterns.

The .NET 6 Lambda runtime was introduced by AWS on February 24. Among the new capablities enabled is improved logging, with better traceability and control of what is being logged. The .NET 6 Lambda runtime allows the Lambda request ID to be added to logs, similar to other AWS Lambda runtimes. Also, several new logging APIs are available including LogCritical, LogError, and LogTrace. Developers still can use the style of logging from previous .NET managed runtimes if they prefer.

The .NET 6 Lambda runtime supports writing Lambda functions using C# 9 top-level statements, which allow developers to delete much of the initial boilerplate code for a .NET project. Microsoft .NET 6 introduced a new style of writing ASP.NET Core applications, called Minimal APIs, which take advantage of C# 9 top-level statements to simplify the initialization of an application. Developers can define an entire application in a single file. Microsoft .NET 6 also introduced the C# 10 and F# 6 languages.

AWS Lambda is Amazon Web Services’ popular event-driven, serverless computing platform. Developers can create an AWS account at portal.aws.amazon.com. To migrate existing .NET Lamdba functions to .NET 6, developers can do the following:

  1. Open the csproj or fsproj file. Set the TargetFramework element to net6.0.
  2. If it exists, open the aws-lambda-tools-defaults.json file.
  3. Set the function-runtime field to dotnet6.
  4. Set the framework field to net6.0. If you remove the field, the value is inferred from the project file.
  5. If it exists, open the serverless.template file. For any AWS::Lambda::Function or AWS::Servereless::Function resource, set the Runtime property to dotnet6.
  6. Update all Amazon.Lambda.* NuGet package references to the latest versions.

With .NET and AWS Lambda, developers can use the tool of their choice, including the Microsoft Visual Studio 2022 IDE, with the AWS Toolkit for Visual Studio, the .NET CLI with Amazon Lambda Tools, and the AWS Serverless Application Model CLI (AWS SAM CLI). The .NET 6 Lambda managed runtime supports x86 and Arm/Graviton processors.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author