Build and deploy C# Lambda functions with .zip file archives - 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).

Build and deploy C# Lambda functions with .zip file archives

A .NET deployment package (.zip file archive) contains your function's compiled assembly along with all of its assembly dependencies. The package also contains a proj.deps.json file. This signals to the .NET runtime all of your function's dependencies and a proj.runtimeconfig.json file, which is used to configure the runtime.

To deploy individual Lambda functions, you can use the Amazon.Lambda.Tools .NET Lambda Global CLI. Using the dotnet lambda deploy-function command automatically creates a .zip deployment package and deploys it to Lambda. However, we recommend that you use frameworks like the Amazon Serverless Application Model (Amazon SAM) or the Amazon Cloud Development Kit (Amazon CDK) to deploy your .NET applications to Amazon.

Serverless applications usually comprise a combination of Lambda functions and other managed Amazon Web Services working together to perform a particular business task. Amazon SAM and Amazon CDK simplify building and deploying Lambda functions with other Amazon Web Services at scale. The Amazon SAM template specification provides a simple and clean syntax to describe Lambda functions, APIs, permissions, configurations, and other Amazon resources that make up your serverless application. With the Amazon CDK you define cloud infrastructure as code to help you build reliable, scalable, cost-effective applications in the cloud using modern programming languages and frameworks like .NET. Both the Amazon CDK and the Amazon SAM use the .NET Lambda Global CLI to package your functions.

While it's possible to use Lambda layers with functions in C# by using the .NET Core CLI, we recommend against it. Functions in C# that use layers manually load the shared assemblies into memory during the Init phase, which can increase cold start times. Instead, include all shared code at compile time to take advantage of the built-in optimizations of the .NET compiler.

You can find instructions for building and deploying .NET Lambda functions using the Amazon SAM, the Amazon CDK, and the .NET Lambda Global CLI in the following sections.