Create Serverless Application using AWS Lambda
Purpose & Background
The purpose of this lab is to demonstrate how you create serverless application using AWS Toolkit project template in Visual Studio and publish it to AWS Lambda. You will need to have a working AWS account to use this lab.
The following exercises should be completed in order for this lab:
- Create an AWS Serverless application
- Publish the application to AWS Lambda
- Test the application within Visual Studio
- Check and verify your AWS serverless application in the Console
The following are the prerequisites required in order to complete the lab:
- Microsoft Visual Studio 2017 or above installed on your computer
- AWS Toolkit for Visual Studio 2017
- AWS Account and IAM user with security key id and secret code Internet connection
Part 1 – Create an AWS Serverless application
In this part you are going to create the AWS serverless application using project template from the AWS Toolkit for Visual Studio.
- Go to File -> New -> Projects and select AWS Lambda in the left side and select “AWS Serverless Application (.NET Core)”
- In the Select Blueprint windows, make sure to select “Simple S3 Function” and click “Finish”
- Visual Studio will create the project and you will have C# source file, CloudFormation template, and JSON configuration file
- Edit the function, add a string “Please provide S3 event” as shown here
- Build the project to make sure it has no errors so you can publish to AWS Lambda.
Part 2 – Publish the application to AWS Lambda
- Right click on the project name and select “Publish to AWS Lambda”
- Make sure to select the region that you want to use, and enter the name of the Stack (CloudFormation stack), then click “Next”
- Enter the name of the new S3 bucket that you want to use with this AWS Lambda function, then click “Publish”
- The AWS Toolkit will start publishing the serverless application,
- After that, it will start creating the stack, and you will be able to see the progress as shown here
- Wait for couple of minutes and you will see that the process is complete,
- If you refresh the “AWS Explorer”, you will be able to see the new AWS Lambda function that you just created and published there under the “AWS Lambda” node.
Part 3 – Test the application within Visual Studio
- Double click on the function name, this will open the window where you can run and test your AWS Lambda function
- Click on the “Invoke” button
Part 4 – Check and verify your AWS serverless application in the Console 1. Go to AWS Console https://aws.amazon.com and sign in 2. Go to Lambda section under “Compute” section 3. You will see the AWS Lambda that you just created