Building Lambda functions with C# - AWS Lambda

Building Lambda functions with C#

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

AWS Lambda provides the following libraries for C# functions:

  • Amazon.Lambda.Core – This library provides a static Lambda logger, serialization interfaces and a context object. The Context object (AWS 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 AWS 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

These packages are available at Nuget packages.

.NET runtimes
Name Identifier Operating system

.NET Core 3.1

dotnetcore3.1

Amazon Linux 2

.NET Core 2.1

dotnetcore2.1

Amazon Linux

Note

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, AWS X-Ray tracing, unit tests, and the AWS SDK.

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