Amazon Lambda projects - Amazon SDK for .NET (V4)
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).

Version 4 (V4) of the Amazon SDK for .NET has been released!

For information about breaking changes and migrating your applications, see the migration topic.

Amazon Lambda projects

Amazon Lambda is a compute service that lets you run code without provisioning or managing servers. It runs your code on a high availability compute infrastructure and performs all of the administration of the compute resources. For more information about Lambda, see What is Amazon Lambda? in the Amazon Lambda Developer Guide.

You can deploy Lambda functions by using the .NET command line interface (CLI).

Prerequisites

Before you start using the .NET CLI to deploy Lambda functions, you must meet the following prerequisites:

  • Confirm that you have the .NET CLI installed. For example: dotnet --version. If needed, go to https://dotnet.microsoft.com/download to install it.

  • Set up the .NET CLI to work with Lambda. For a description of how to do so, see .NET Core CLI in the Amazon Lambda Developer Guide. In that procedure, the following is the deployment command:

    dotnet lambda deploy-function MyFunction --function-role role

    If you're not sure how to create an IAM role for this exercise, don't include the --function-role role part. The tool will help you create a new role.

Available Lambda commands

To list the Lambda commands that are available through the .NET CLI, open a command prompt or terminal and enter dotnet lambda --help. The command output will be similar to the following:

Amazon Lambda Tools for .NET applications Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet Commands to deploy and manage AWS Lambda functions: deploy-function Command to deploy the project to AWS Lambda ... (etc.) To get help on individual commands execute: dotnet lambda help <command>

The output lists all the commands that are currently available.

Steps to deploy

The following instructions assume that you've created an Amazon Lambda .NET project. For the purposes of this procedure, the project is named DotNetCoreLambdaTest.

  1. Open a command prompt or terminal, and navigate to the folder containing your .NET Lambda project file.

  2. Enter dotnet lambda deploy-function.

  3. If prompted, enter the Amazon Region (the Region to which your Lambda function will be deployed).

  4. When prompted, enter the name of the function to deploy, for example, DotNetCoreLambdaTest. It can be the name of a function that already exists in your Amazon Web Services account or one that hasn't been deployed there yet.

  5. When prompted, select or create the IAM role that Lambda will assume when executing the function.

After successful completion, the message New Lambda function created is displayed.

Executing publish command ... (etc.) New Lambda function created

If you deploy a function that already exists in your account, the deploy function asks only for the Amazon Region (if necessary). In this case, the command output ends with Updating code for existing function.

After your Lambda function is deployed, it's ready to use. For more information, see Examples of How to Use Amazon Lambda.

Lambda automatically monitors Lambda functions for you and reports metrics through Amazon CloudWatch. To monitor and troubleshoot your Lambda function, see Monitoring and troubleshooting Lambda applications.