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

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 AWS Serverless Application Model (AWS SAM) or the AWS Cloud Development Kit (AWS CDK) to deploy your .NET applications to AWS.

Serverless applications usually comprise a combination of Lambda functions and other managed AWS services working together to perform a particular business task. AWS SAM and AWS CDK simplify building and deploying Lambda functions with other AWS services at scale. The AWS SAM template specification provides a simple and clean syntax to describe Lambda functions, APIs, permissions, configurations, and other AWS resources that make up your serverless application. With the AWS 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 AWS CDK and the AWS 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 AWS SAM, the AWS CDK, and the .NET Lambda Global CLI in the following sections.