Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News AWS Introduces the .NET Annotations Lambda Framework in Preview

AWS Introduces the .NET Annotations Lambda Framework in Preview

This item in japanese

Recently, AWS introduced a new framework for writing .NET 6 Lambda functions called Lambda Annotations. This framework was built alongside the .NET 6 managed runtime for Lambda released last February.

Lambda Annotations is a programming model for writing .NET Lambda functions. It bridges the gap between the Lambda programming model and the more idiomatic programming model; the programming model permits idiomatic.NET coding patterns and leverages C# Source Generators.

In an AWS Developer Tools blog post, Norm Johanson, a software developer engineer at, explains:

The Annotations framework makes the experience of writing Lambda feel more natural in C#. It also takes care of synchronizing the Lambda functions implemented in your code with your project’s CloudFormation template. This means you don’t have to worry about function handler strings not being set correctly in CloudFormation templates or lose focus while coding to also update your CloudFormation JSON or YAML template.

Johanson also mentions that when the C# compiler is used to create the project, the Annotations framework looks for the .NET Lambda properties that indicate Lambda functions and adds extra code to the build that handles the translation. It will also sync the generated information, including a new function handler string, into the CloudFormation template. In addition, Johanson states that using the C# source generators is a way to create the translation layer at compile time that avoids reflection code at runtime.

Developers can use the new framework through the AWS Toolkit for Visual Studio 2022. With the Microsoft Integrated Development Environment (IDE), they can create a project with the available AWS Serverless Application project template - allowing them to write one or more Lambda functions and deploy them to AWS using AWS CloudFormation, along with any other required AWS resources, as a single unit of deployment.


Once the project is created, there is a dependency on Amazon.Lambda.Annotations NuGet package, which includes the.NET properties used to annotate Lambda code and the C# source generator that generates the produced translation code. Furthermore, the Annotations framework makes it easy to configure dependency injection for Lambda functions using the LambdaStartup attribute.

The official .NET on AWS twitter handler stated in a tweet:

Now you can replace the regular AWS Lambda program model with a simpler version and just focus on business logic.

Lastly, the development of the framework is in the aws/aws-lambda-dotnet GitHub repository.

About the Author

Rate this Article