Skip to content

jcmdsbr/poc-aspnetcore-aws-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sample Serverless Application hosted by AWS Lambda 😎

  • This project shows how to run an ASP.NET Core Web API project as an AWS Lambda exposed through Amazon API Gateway.

Give a Star! ⭐

If you liked the project, please give a star ;)

You need some of the fallowing tools ❗

  • Visual Studio 2019 or Visual Studio Code
  • .Net Core 2.X

Description 📚

To integrate the AWS SDK for .NET with the dependency injection system built into ASP.NET Core the NuGet package AWSSDK.Extensions.NETCore.Setup is referenced. In the Startup.cs file the Amazon S3 client is added to the dependency injection framework. The S3ProxyController will get its S3 service client from there.

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddAWSService<Amazon.S3.IAmazonS3>();
}

Application Load Balancer 💡

To configure this project to handle requests from an Application Load Balancer instead of API Gateway change the base class of LambdaEntryPoint from Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction.

Startup ✔️

Once you have edited your template and code you can deploy your application using the Amazon.Lambda.Tools Global Tool from the command line.

Install Amazon.Lambda.Tools Global Tools if not already installed.

    dotnet tool install -g Amazon.Lambda.Tools

If already installed check if new version is available.

    dotnet tool update -g Amazon.Lambda.Tools

Execute unit tests

    cd "LambdaShoppingListWebAi/test/LambdaShoppingListWebAi.Tests"
    dotnet test

Deploy application

    cd "LambdaShoppingListWebAi/src/LambdaShoppingListWebAi"
    dotnet lambda deploy-serverless