question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Design Doc: Lambda Annotation

See original GitHub issue

The AWS .NET team is working on a new library for constructing .NET Lambda functions. The design doc can be viewed and commented on in this PR https://github.com/aws/aws-lambda-dotnet/pull/961.

The high level overview of the new library is to use .NET source generator support to translating from the low level single event object programming model of Lambda to an experience similar to ASP.NET Core but with minimal overhead. The initial work is focused on REST API Lambda functions but the technology is applicable for other Lambda event types.

For example developers will be able to write a Lambda function like the following with the ICalculator service being injected by dependency injection and and the LambdaFunction and HttpApi attributes directing the source generator to generator the compatible Lambda boiler plate code and sync with the CloudFormation template.

public class Functions
{
	ICalculator _calulator;

	public Functions(ICalculator calculator)
	{
		_calulator = calculator;
	}

	[LambdaFunction]
	[HttpApi(HttpMethod.Get, HttpApiVersion.V2, "/add/{x}/{y}")]
	public int Add(int x, int y)
	{
		return _calulator.Add(x, y);
	}
}

We would appreciate feedback on the design. What use cases what you like this library to help solve and what boiler plate code can we remove from your applications to make it simple to write Lambda functions.


Update 12/21/2021

We are excited to announce that Lambda Annotations first preview is here. Developers using the preview version of Amazon.Lambda.Annotations NuGet package can start using the simplified programming model to write REST and HTTP API Lambda functions on .NET 6. (Only Image package type is supported as of now)

Example (sample project)

[LambdaFunction(Name = "CalculatorAdd", PackageType = LambdaPackageType.Image)]
[RestApi(HttpMethod.Get, "/Calculator/Add/{x}/{y}")]
public int Add(int x, int y, [FromServices]ICalculatorService calculatorService)
{
    return calculatorService.Add(x, y);
}
[LambdaStartup]
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<ICalculatorService, CalculatorService>();
    }
}

Learn more about the Lambda Annotations and supported feature set here.

We cannot overstate how critical your feedback is as we move forward in the development. Let us know your experience working with Lambda Annotations in GitHub issues.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:33
  • Comments:59 (26 by maintainers)

github_iconTop GitHub Comments

9reactions
Lanayxcommented, Nov 17, 2021

Source generators is not dotnet, but csharp technology, so will be applicable only to csharp, with fsharp it won’t be usable.

5reactions
normjcommented, Feb 25, 2022

As part of the .NET 6 managed runtime release we added a blueprint in Visual Studio that uses this preview library. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

lambda-annotations-design.md
The Lambda Annotation design is a new programming model for writing .NET Lambda function. At a high level the new programming model allows...
Read more >
Introducing .NET Annotations Lambda Framework (Preview)
NET 6 Lambda functions called Lambda Annotations. The Annotations framework makes the experience of writing Lambda feel more natural in C#.
Read more >
Adopting the Lambda Annotations Framework
Hopefully, this post will have intrigued you enough to check out the new framework, and try converting some of your existing functions into...
Read more >
.NET Lambda Annotations Framework Now Generally Available
NET Lambda Annotations Framework is now generally available. It simplifies AWS Lambda development for .NET developers using custom ...
Read more >
How do you design and document lambda functions ...
Use type annotations and docstrings. Another way to improve the readability and maintainability of your lambda functions and applications is to use type ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found