AWS Lambda projects
AWS 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 AWS Lambda? in the AWS 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/downloadto 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 AWS 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 AWS Lambda .NET project. For the purposes of
this procedure, the project is named DotNetCoreLambdaTest
.
-
Open a command prompt or terminal, and navigate to the folder containing your .NET Lambda project file.
-
Enter
dotnet lambda deploy-function
. -
If prompted, enter the AWS Region (the Region to which your Lambda function will be deployed).
-
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 AWS account or one that hasn't been deployed there yet. -
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
AWS 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 AWS 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.