Building Lambda functions with C# - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Building Lambda functions with C#

The following sections explain how common programming patterns and core concepts apply when authoring Lambda function code in C#.

Amazon Lambda provides the following libraries for C# functions. These packages are available as Nuget packages.

Tools and libraries for C#
  • Amazon.Lambda.Core – This library provides a static Lambda logger, serialization interfaces and a context object. The Context object (Amazon Lambda context object in C#) provides runtime information about your Lambda function.

  • Amazon.Lambda.Serialization.Json – This is an implementation of the serialization interface in Amazon.Lambda.Core.

  • Amazon.Lambda.Logging.AspNetCore – This provides a library for logging from ASP.NET.

  • Event objects (POCOs) for several Amazon services, including:

    • Amazon.Lambda.APIGatewayEvents

    • Amazon.Lambda.CognitoEvents

    • Amazon.Lambda.ConfigEvents

    • Amazon.Lambda.DynamoDBEvents

    • Amazon.Lambda.KinesisEvents

    • Amazon.Lambda.S3Events

    • Amazon.Lambda.SQSEvents

    • Amazon.Lambda.SNSEvents

Lambda provides the following runtimes for .NET languages:

Name Identifier Operating system Architectures Deprecation (Phase 1)

.NET 7 (container only)


Amazon Linux 2

x86_64, arm64

May 14, 2024

.NET 6


Amazon Linux 2

x86_64, arm64

To get started with application development in your local environment, deploy one of the sample applications available in this guide's GitHub repository.

Sample Lambda applications in C#
  • blank-csharp – A C# function that shows the use of Lambda's .NET libraries, logging, environment variables, Amazon X-Ray tracing, unit tests, and the Amazon SDK.

  • blank-csharp-with-layer – A C# function that uses the .NET CLI to create a layer that packages the function's dependencies.

  • ec2-spot – A function that manages spot instance requests in Amazon EC2.