AWS Toolkit for Visual Studio - AWS Lambda

AWS Toolkit for Visual Studio

You can build .NET-based Lambda applications using the Lambda plugin to the AWS Toolkit for Visual Studio. The toolkit is available as a Visual Studio extension.

  1. Launch Microsoft Visual Studio and choose New project.

    1. From the File menu, choose New, and then choose Project.

    2. In the New Project window, choose Lambda Project (.NET Core), and then choose OK.

    3. In the Select Blueprint window, you can select from a list of sample applications that provide you with sample code to get started with creating a .NET-based Lambda application.

    4. To create a Lambda application from scratch, choose Empty Function, and then choose Finish.

  2. Review the aws-lambda-tools-defaults.json file, which is created as part of your project. You can set the options in this file, which the Lambda tooling reads by default. The project templates created in Visual Studio set many of these fields with default values. Note the following fields:

    • profile – The name of a profile in your AWS SDK for .NET credentials file

    • function-handler – This is where the function handler is specified, which is why you don't have to set it in the wizard. However, whenever you rename the Assembly, Namespace, Class, or Function in your function code, you must update the corresponding fields in the aws-lambda-tools-defaults.json file.

      { "profile":"default", "region" : "us-east-2", "configuration" : "Release", "framework" : "netcoreapp2.1", "function-runtime":"dotnetcore3.1", "function-memory-size" : 256, "function-timeout" : 30, "function-handler" : "Assembly::Namespace.Class::Function" }
  3. Open the Function.cs file. You are provided with a template to implement your Lambda function handler code.

  4. Once you have written the code that represents your Lambda function, upload it by opening the context (right-click) menu for the Project node in your application and then choosing Publish to AWS Lambda.

  5. In the Upload Lambda Function window, enter a name for the function, or select a previously published function to republish. Then choose Next.

  6. In the Advanced Function Details window, configure the following options:

  7. Choose Next, and then choose Upload to deploy your application.

For more information, see Deploying an AWS Lambda Project with the .NET Core CLI.