![]() |
VOOZH | about |
dotnet add package Amazon.Lambda.Core --version 3.1.0
NuGet\Install-Package Amazon.Lambda.Core -Version 3.1.0
<PackageReference Include="Amazon.Lambda.Core" Version="3.1.0" />
<PackageVersion Include="Amazon.Lambda.Core" Version="3.1.0" />Directory.Packages.props
<PackageReference Include="Amazon.Lambda.Core" />Project file
paket add Amazon.Lambda.Core --version 3.1.0
#r "nuget: Amazon.Lambda.Core, 3.1.0"
#:package Amazon.Lambda.Core@3.1.0
#addin nuget:?package=Amazon.Lambda.Core&version=3.1.0Install as a Cake Addin
#tool nuget:?package=Amazon.Lambda.Core&version=3.1.0Install as a Cake Tool
This package contains interfaces and classes that can be helpful when running your .NET code on the AWS Lambda platform.
The interface can be used in your handler function to access information about the current execution, such as the name of the current function, the memory limit, execution time remaining, and logging.
Here is an example of how this interface can be used in your handler function. The function performs a simple ToUpper content transformation, while writing some context data to Console.
public string ToUpper(string input, ILambdaContext context)
{
Console.WriteLine("Function name: " + context.FunctionName);
Console.WriteLine("Max mem allocated: " + context.MemoryLimitInMB);
Console.WriteLine("Time remaining: " + context.RemainingTime);
Console.WriteLine("CloudWatch log stream name: " + context.LogStreamName);
Console.WriteLine("CloudWatch log group name: " + context.LogGroupName);
return input?.ToUpper();
}
An instance of this interface is attached to any ControllerBase.Request.HttpContext instances via the Items property using the key ""
Here is an example of how you can use this interface in a controller method.
[ApiController]
public class TestController : ControllerBase
{
[HttpGet("/[controller]")]
public IActionResult Get()
{
Response.Headers.Add("Access-Control-Allow-Origin", "*"); // NOTE: Should be configured via app.UseCors in Startup.cs
var context = (ILambdaContext)Request.HttpContext.Items[APIGatewayProxyFunction.LAMBDA_CONTEXT];
var tmp = new
{
context.AwsRequestId,
context.FunctionName,
context.MemoryLimitInMB,
context.LogStreamName,
context.LogGroupName
};
return new OkObjectResult(tmp);
}
}
The following sections describe various other interfaces which are accessible through the ILambdaContext.
The Amazon.Lambda.Core.IClientContext interface provides information about the client application and device when the Lambda function is invoked through the AWS Mobile SDK. This includes environment information such as make and model of the device, information about the application, as well as use-defined name-value pairs that describe this installation of the application.
This interface can be found under ILambdaContext.ClientContext.
The Amazon.Lambda.Core.IClientApplication interface provides information about the client application when the Lambda function is invoked through the AWS Mobile SDK. This includes the application title, its version, etc.
This interface can be found under ILambdaContext.ClientContext.Client.
The Amazon.Lambda.Core.ICognitoIdentity interface provides Information about the Amazon Cognito identity provider when invoked through the AWS Mobile SDK. This includes the Amazon Cognito IdentityId and IdentityPoolId.
This interface can be found under ILambdaContext.Identity.
The Amazon.Lambda.Core.ILambdaLogger interface allows your function to log data to CloudWatch. This interface defines methods Log and LogLine. Both take a string and result in a CloudWatch Logs event, with or without a line terminator, provided that the event size is within the allowed limits.
Here is an example of how this interface can be used in your handler function. The function performs a simple ToUpper content transformation, while logging the context data.
public string ToUpper(string input, ILambdaContext context)
{
context.Logger.Log("Function name: " + context.FunctionName);
context.Logger.Log("Max mem allocated: " + context.MemoryLimitInMB);
context.Logger.Log("Time remaining: " + context.RemainingTime);
return input?.ToUpper();
}
The Amazon.Lambda.Core.ILambdaSerializer interface allows you to implement a custom serializer to convert between arbitrary types and Lambda streams.
By default, Lambda functions can only use Stream types as inputs or outputs. To use other types, you can either write your own serializer that implements ILambdaSerializer, or use the Amazon.Lambda.Serialization.Json package to serialize and deserialize JSON data.
See Amazon.Lambda.Serialization.Json.JsonSerializer class for a sample implementation of ILambdaSerializer.
The Amazon.Lambda.Core.LambdaSerializerAttribute is an attribute that can is used to instruct the Lambda container what serializer to use when converting .NET types to Lambda-supported types.
This attribute can be present on the assembly or on the handler method. If you specify both, the method attribute takes priority.
Here is an example of setting this attribute on the assembly.
[assembly: Amazon.Lambda.Core.LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
And this is how the method can be applied to the handler method.
[LambdaSerializer(typeof(XmlSerializer))]
public Response CustomSerializerMethod(Request input)
{
...
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Amazon.Lambda.Core:
| Package | Downloads |
|---|---|
|
Amazon.Lambda.Serialization.SystemTextJson
Amazon Lambda .NET Core support - Serialization.Json with System.Text.Json. |
|
|
Amazon.Lambda.Logging.AspNetCore
Amazon Lambda .NET Core support - Logging ASP.NET Core package. |
|
|
Amazon.Lambda.Serialization.Json
Amazon Lambda .NET Core support - Serialization.Json package. |
|
|
AWSXRayRecorder.Core
The AWS X-Ray Recorder core runtime. |
|
|
Amazon.Lambda.AspNetCoreServer
Amazon.Lambda.AspNetCoreServer makes it easy to run ASP.NET Core Web API applications as AWS Lambda functions. |
Showing the top 20 popular GitHub repositories that depend on Amazon.Lambda.Core:
| Repository | Stars |
|---|---|
|
lambci/docker-lambda
Docker images and test runners that replicate the live AWS Lambda environment
|
|
|
mongodb/mongo-csharp-driver
The Official C# .NET Driver for MongoDB
|
|
|
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK.
|
|
|
awslabs/aws-apigateway-lambda-authorizer-blueprints
Blueprints and examples for Lambda-based custom Authorizers for use in API Gateway.
|
|
|
TelegramBots/Telegram.Bot.Examples
Examples for the Telegram.Bot C# Library
|
|
|
open-telemetry/opentelemetry-dotnet-contrib
This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
|
|
|
exceptionless/Exceptionless.Net
Exceptionless clients for the .NET platform
|
|
|
DataDog/dd-trace-dotnet
.NET Client Library for Datadog APM
|
|
|
aws/aws-extensions-for-dotnet-cli
Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
|
|
|
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
|
|
| Elfocrash/aws-videos | |
|
Illumina/Nirvana
The nimble & robust variant annotator
|
|
| jorgevgut/airquality-mx | |
|
aws-powertools/powertools-lambda-dotnet
Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
|
|
|
PowerShellOrg/tug
Open-source, cross-platform Pull/Reporting Server for DSC
|
|
| aws-samples/serverless-dotnet-demo | |
|
cmendible/dotnetcore.samples
.NET Core Samples - Code it Yourself...
|
|
|
aws/integrations-on-dotnet-aspire-for-aws
This repositry contains the integrations with .NET Aspire for AWS.
|
|
|
aws/porting-assistant-dotnet-client
The 'Porting Assistant for .NET' is a standalone compatibility analyzer that helps customers to port their .NET Framework (“.NET”) applications to .NET Core on Linux.
|
|
|
aws/aws-dotnet-messaging
An AWS-native framework that simplifies the development of .NET message processing applications that use AWS services, such as SQS, SNS, and EventBridge.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.0 | 276,754 | 5/18/2026 |
| 3.0.0 | 289,691 | 5/7/2026 |
| 2.8.1 | 2,454,404 | 2/4/2026 |
| 2.8.0 | 4,897,468 | 11/6/2025 |
| 2.7.1 | 2,307,627 | 9/18/2025 |
| 2.7.0 | 4,784,523 | 7/15/2025 |
| 2.6.0 | 2,712,232 | 6/3/2025 |
| 2.5.1 | 3,852,424 | 3/14/2025 |
| 2.5.0 | 9,840,027 | 11/18/2024 |
| 2.4.0 | 1,709,325 | 11/7/2024 |
| 2.3.0 | 12,313,291 | 9/5/2024 |
| 2.2.0 | 25,771,588 | 10/26/2023 |
| 2.1.0 | 40,975,248 | 11/5/2021 |
| 2.0.0 | 19,307,727 | 3/30/2021 |
| 1.2.0 | 14,273,924 | 10/21/2020 |
| 1.1.0 | 15,572,775 | 2/7/2019 |
| 1.0.0 | 11,425,559 | 12/1/2016 |