Create ASP.NET Core Web API project.
Install Amazon.Lambda.AspNetCoreServer.Hosting
NuGet package.
Add a call to AddAWSLambdaHosting
method when services are defined in your application.
// Add AWS Lambda support.
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);
var app = builder.Build();
Open .csproj
file and add the following tag in the PropertyGroup section.
<AWSProjectType>Lambda</AWSProjectType>
Now, You’re done with the API stuff for this demo.
Create Lambda function in AWS Console.
Deploy to AWS, when deploying, keep the function handler name the same as Assembly Name.
Exposing the Web API using Amazon API Gateway
Configure proxy integration, and deploy the API
b. Update Lambda code to use LambdaEventSource.RestAPI
instead.
// Add AWS Lambda support.
builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);
var app = builder.Build();