The purpose of this blog is to create a simple aws lambda using dotnet core and deploy it on aws using cloud formation.
To create AWS Lambda function, you must have installed Visual Studio 2019 and AWS toolkit for visual studio. AWS toolkit is an extension for visual studio that lets you create, debug and deploy dot-net applications using visual studio.
Once you have installed the AWS Toolkit then restart the visual studio and and select create a new project. Then select below project template.
Now there are many templates available to perform various tasks. Here we want to learn how to create simple Lambda function and deploy it on cloud so we will select empty function template.
Now you got the template with one Lambda project and one test project.
Lets focus on the Lambda project first. Here you will get one Function.cs file which hold your Lambda function definition. Over here you will see the assembly attribute to serialize your Lambda json to class type.
Then you have the Function class with a FunctionHandler accepting string input and ILambdaContext. ILambdaContext contains the information of incoming request.
You can run this Function with the Mock Lambda Test Tool.
after executing the lambda function, you will the output on the browser. You lambda function is running on the localhost:5050. As you can see I entered a string in lower case “neeraj vishwakaram” which has been converted in upper case after execution of the function. Here you can run multiple AWS lambda function one by one. You just need to select the function from the drop down and the config from the Config File drop down.
It shows that the function is running correctly. In the next blog we will deploy the aws lambda function. To deploy the lambda function we will user the cloud formation which is wide topic and this we will discuss in other blog.