News

AWS Launches Preview of .NET Annotations Lambda Framework

On the heels of releasing the .NET 6 managed runtime for AWS Lambda, Amazon Web Services (AWS) has released a preview of the .NET Annotations Lambda Framework.

The idea of the new Annotations framework is to provide a high-level library to simplify writing .NET Lambda functions in a more idiomatic -- natural to C# and .NET 6 -- manner, along with other benefits such as synchronization of Lambda functions with the CloudFormation (an infrastructure automation platform) template associated with a specific project.

The net effect (no pun intended) is to simplify coding, with AWS providing an example of how code used in the normal Lambda programming model can become much simpler by removing typical Lambda function code through the use of two .NET attributes that annotate the code.

A C# construct, source generators, are used to bridge the gap between the Lambda Annotations programming model and the normal, more idiomatic, programming model. Source generators let C# developers inspect user code and generate new source files that can be added during compilation. At a high level, AWS explained that the new library uses .NET source generator support to translate from the low-level, single-event, object programming model of Lambda to an experience more akin to ASP.NET Core with minimal overhead. Because source generators are a C# thing, F# coders are left out of the Annotations party.

"After adding the attributes to your .NET code the source generator will generate the translation code between the two programming models," AWS said. "It will also keep in sync the generated information including a new function handler string into the CloudFormation template. The usage of source generator is transparent to the user."

The Amazon.Lambda.Annotations NuGet package contains the .NET attributes used to annotate the code for Lambda, along with the C# source generator used to create the generated translation code. It has been downloaded more than 221,000 times.

For now, the preview offering only supports Lambda functions leveraging REST APIs, but AWS hopes to simplify other event sources like S3 and DynamoDB events in the future.

About the Author

David Ramel is an editor and writer for Converge360.

Featured

Subscribe on YouTube