Why .NET on Lambda?
AWS Lambda supports .NET 10 natively. Combined with ARM64 Graviton2 processors, you get better price-performance than x86.
Lambda Handler
public class Function
{
public async Task<APIGatewayProxyResponse> Handler(
APIGatewayProxyRequest request, ILambdaContext ctx)
{
return new APIGatewayProxyResponse
{
StatusCode = 200,
Body = JsonSerializer.Serialize(new { message = "Hello from .NET 10" })
};
}
}
Eliminating Cold Starts with SnapStart
# serverless.yml
functions:
api:
handler: MyApp::MyApp.Function::Handler
runtime: dotnet10
architecture: arm64
snapStart: true
âš¡
ARM64 Graviton2 is ~20% cheaper and ~19% faster than x86 for most .NET workloads. Switch unless you have x86-specific native dependencies.
Lambda Layers for Shared Code
Package shared libraries as Lambda Layers to reduce deployment package size and share code across functions.