Amazon.Lambda.AspNetCoreServer.Hosting
1.10.0
Prefix Reserved
dotnet add package Amazon.Lambda.AspNetCoreServer.Hosting --version 1.10.0
NuGet\Install-Package Amazon.Lambda.AspNetCoreServer.Hosting -Version 1.10.0
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.10.0" />
<PackageVersion Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.10.0" />
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" />
paket add Amazon.Lambda.AspNetCoreServer.Hosting --version 1.10.0
#r "nuget: Amazon.Lambda.AspNetCoreServer.Hosting, 1.10.0"
#:package Amazon.Lambda.AspNetCoreServer.Hosting@1.10.0
#addin nuget:?package=Amazon.Lambda.AspNetCoreServer.Hosting&version=1.10.0
#tool nuget:?package=Amazon.Lambda.AspNetCoreServer.Hosting&version=1.10.0
Amazon.Lambda.AspNetCoreServer.Hosting
This package allows ASP .NET Core applications written using the minimal api style to be deployed
as AWS Lambda functions. This is done by adding a call to AddAWSLambdaHosting to the
services collection of the application. This method takes in the LambdaEventSource enum
that configures which Lambda event source the Lambda function will be configured for.
The AddAWSLambdaHosting will setup the Amazon.Lambda.AspNetCoreServer package to process
the incoming Lambda events as ASP .NET Core requests. It will also initialize Amazon.Lambda.RuntimeSupport package to interact with the Lambda service.
Supported .NET versions
This library supports .NET 6 and above. Lambda provides managed runtimes for long term supported (LTS) versions like .NET 6 and .NET 8. To use standard term supported (STS) versions like .NET 9 the Lambda function must be bundled as a self contained executable or an OCI image.
Sample ASP .NET Core application
The code sample below is the typical initilization code for an ASP .NET Core application using the minimal api style. The one difference is the extra line of code calling AddAWSLambdaHosting.
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Register Lambda to replace Kestrel as the web server for the ASP.NET Core application.
// If the application is not running in Lambda then this method will do nothing.
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
Extension Points
AddAWSLambdaHosting accepts an optional HostingOptions configuration action that exposes the same customization hooks available in the traditional AbstractAspNetCoreFunction base class approach.
Binary response handling
By default, common binary content types like image/png and application/pdf are already configured for Base64 encoding. You can register additional types or override the default encoding:
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
// Register a custom binary content type
options.RegisterResponseContentEncodingForContentType("application/x-custom-binary", ResponseContentEncoding.Base64);
// Ensure compressed responses are Base64-encoded (gzip, deflate, br are already defaults)
options.RegisterResponseContentEncodingForContentEncoding("zstd", ResponseContentEncoding.Base64);
// Change the fallback encoding for any unregistered content type
options.DefaultResponseContentEncoding = ResponseContentEncoding.Base64;
});
Exception details in responses
Useful during development to surface unhandled exception details in the HTTP response body:
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
options.IncludeUnhandledExceptionDetailInResponse = app.Environment.IsDevelopment();
});
Customizing request and response marshalling
Callbacks let you inspect or modify the ASP.NET Core feature objects after the Lambda event has been marshalled into them. The second parameter is the raw Lambda request or response object — cast it to the appropriate type for your event source (APIGatewayHttpApiV2ProxyRequest for HttpApi, APIGatewayProxyRequest for RestApi, ApplicationLoadBalancerRequest for ApplicationLoadBalancer).
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
// Add a custom header derived from the raw Lambda request
options.PostMarshallRequestFeature = (requestFeature, lambdaRequest, context) =>
{
var apiRequest = (APIGatewayHttpApiV2ProxyRequest)lambdaRequest;
requestFeature.Headers["X-Stage"] = apiRequest.RequestContext.Stage;
};
// Inject the Lambda context into HttpContext.Items for use in middleware or controllers
options.PostMarshallItemsFeature = (itemsFeature, lambdaRequest, context) =>
{
itemsFeature.Items["MyCustomKey"] = context.FunctionName;
};
// Modify the response after it has been marshalled back to a Lambda response
options.PostMarshallResponseFeature = (responseFeature, lambdaResponse, context) =>
{
var apiResponse = (APIGatewayHttpApiV2ProxyResponse)lambdaResponse;
apiResponse.Headers ??= new Dictionary<string, string>();
apiResponse.Headers["X-Request-Id"] = context.AwsRequestId;
};
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Amazon.Lambda.APIGatewayEvents (>= 2.7.3)
- Amazon.Lambda.AspNetCoreServer (>= 9.2.1)
- Amazon.Lambda.Core (>= 2.8.1)
- Amazon.Lambda.RuntimeSupport (>= 1.14.2)
-
net8.0
- Amazon.Lambda.APIGatewayEvents (>= 2.7.3)
- Amazon.Lambda.AspNetCoreServer (>= 9.2.1)
- Amazon.Lambda.Core (>= 2.8.1)
- Amazon.Lambda.RuntimeSupport (>= 1.14.2)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Amazon.Lambda.AspNetCoreServer.Hosting:
| Package | Downloads |
|---|---|
|
Fen.Service
Standardized Service conventions, from the opinions of the Fulfiller Enablement team. |
|
|
Siemens.AspNet.MinimalApi.Sdk
A library which contains following functions: - Siemens.AspNet.MinimalApi.Sdk |
|
|
Siemens.AspNet.Lambda.Sdk.Contracts
The Siemens.AspNet.Lambda.Sdk.Contracts NuGet package simplifies and accelerates the development of AWS Lambda functions using ASP.NET-inspired middleware pipelines, structured exception handling, and pre-configured startup patterns. |
|
|
Siemens.AspNet.DbProvider
A library which contains following functions: - Siemens.AspNet.DbProvider |
|
|
JuegoFramework
Package Description |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Amazon.Lambda.AspNetCoreServer.Hosting:
| Repository | Stars |
|---|---|
|
Elfocrash/aws-videos
|
|
|
aws-samples/serverless-dotnet-demo
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.10.0 | 0 | 2/19/2026 |
| 1.9.1 | 81,071 | 1/12/2026 |
| 1.9.0 | 841,090 | 7/15/2025 |
| 1.8.2 | 193,211 | 6/3/2025 |
| 1.8.1 | 97,057 | 5/15/2025 |
| 1.8.0 | 96,900 | 4/25/2025 |
| 1.7.4 | 481,577 | 2/25/2025 |
| 1.7.3 | 516,727 | 11/26/2024 |
| 1.7.2 | 179,675 | 11/20/2024 |
| 1.7.1 | 613,041 | 9/5/2024 |
| 1.7.0 | 1,346,693 | 2/16/2024 |
| 1.6.1 | 446,300 | 11/14/2023 |
| 1.6.0 | 1,103,585 | 3/24/2023 |
| 1.5.1 | 122,747 | 3/1/2023 |
| 1.5.0 | 292,680 | 12/9/2022 |
| 1.4.0 | 34,125 | 12/7/2022 |
| 1.3.1 | 817,967 | 5/27/2022 |
| 1.3.0 | 113,820 | 5/18/2022 |
| 1.2.0 | 13,035 | 5/7/2022 |
| 1.1.0 | 178,533 | 3/15/2022 |