Deploy your ASP.NET Core Web API to AWS Lambda

Today I’ll show you how to Deploy your ASP.NET Core Web API to AWS Lambda.

First be aware of the following prerequisites:

Now let’s start:

1. Create a folder for your new project
2. Create the project
3. Replace the contents of aws.lambda.csproj
4. Restore the packages
5. Rename Program.cs and replace it's contents
6. Create a file LambdaFunction.cs
7. Replace the contents of Startup.cs
8. Create aws-lambda-tools-defaults.json
9. Create serverless.template
10. Build the application
11. Deploy to AWS Lambda
12. Get your api id
13. Browse to your web api

You can get the code here:

Hope it helps!

4 thoughts on “Deploy your ASP.NET Core Web API to AWS Lambda

  1. First, it seems you have to create the first version by uploading to the bucket and then creating the stack from the browser using the bucket. After that everything can be done per your instruction via the command line. Not sure if I missed a step.

    Second, any idea how to connect to an RDS using this example. Normally I set the IP in the whitelist in the RDS but since this is serverless the IP changes each time.

    1. Hmn thats wierd I’ve followed the steps several times without issue. I’ll check it again and let you know…

      For the second cuestion, haven’t tried it myself but you’ll need to deploy RDS in a VPC and then create your function with VPC access.

Leave a Reply