Deploy RESTful API with .net framework 4.5 in AWS Lambda

+4 votes

What could be the possible issues, I may face when trying to migrate an existing API developed in .NET framework 4.5 and deployed in an IIS to a serverless architecture based on AWS Lambda.

Currently, the API is divided in: 

  • Controller (entry point) 
  • Service (buz logic) 
  • Repository (basically LINQ) 
  • DTO and DAO's. 

In addition, there are some dependencies to external libraries but I don't know if that really matters.

Main Concern:  As I could see when configuring my Lambda, it only accepts .Net Core applications. Then, is it necessary to migrate to .Net Core? If it is, can anyone tell me how much development that requires considering my set up?

Mar 27, 2018 in Cloud Computing by brat_1
• 7,080 points
578 views

3 answers to this question.

+1 vote

It is highly important to pay specific attention to the dependencies to external libraries, because they are required to support .NET core and might add a substantial load time to your lambda function.

If you have an existing .NET API developed in 4.5, it is advisible you try to migrate the whole API. Lambda's pay-for-what-you-use model is  largely incompatible with ASP.NET MVC/WebApi's server model.

answered Mar 27, 2018 by code_ninja
• 6,220 points
0 votes

Is it necessary to migrate to .Net Core?

Yes, as Lambda runs on Linux.

If it is, can anyone tell me how much development that requires considering my set up?

You will need to pay specific attention to the dependencies to external libraries, as they need to support .NET core and might add a substantial load time to your lambda function.

If you have an existing .NET API developed in 4.5, I would strongly advise against trying to migrate the whole API. Lambda's pay-for-what-you-use model is very attractive, but largely incompatible with ASP.NET MVC/WebApi's server model.

answered Oct 11, 2018 by findingbugs
• 4,750 points
+1 vote

This is an old question (somewhat), but I'll add my 2 cents:

First - AWS Lambda functions run in Linux containers under the hood, and currently support .NET Core 2.2.  So you would have to port your code to .NET Core. However, .NET Core 2.2 implements the .NET Standard 2.0 APIs, so if you're not making use of Windows-only libraries (manipulating images, for instance), and instead doing mostly CRUD operations, it may not be so difficult. You can use the .NET Portability Analyzer (free from Microsoft) to analyze your solution to see how much code would need to be refactored.

As someone else pointed out, the dependencies on 3rd-party libraries could be a problem, if those libraries don't adhere to the .NET Standard 2.0 standard (or at least, if the functions you use in them use APIs not in .NET Standard 2.0).  The portability analyzer can check those DLLs also (it works against binaries). 

As a general strategy, for a Web API project to Lambda, I'd suggest carving off individual APIs at a time, implementing them as ASP.NET Core Web APIs (with either a single controller, or a small number) per Lambda, to keep the Lambda size small (improves start-up times).  If your repository code is talking to a relational database (ie, SQL Server), you'll either need to have your database be publicly accessible (not recommended) or run your Lambda function in a VPC (where it gets its own IP address), which means cold-start times will be even slower.  However, you there are ways to keep Lambda containers "warm" (using CloudWatch events, for example).

I have deployed basic ASP.NET Core MVC and Web API projects both to AWS Lambda, but I started them out in .NET Core. As a way to start, try creating a new ASP.NET Core Web API project using the AWS Toolkit for Visual Studio (an extension), using the project types under "Lambda", and choosing "Serverless application", then picking the Web API template. This will also create the API Gateway API, and associate it with your Lambda, when you deploy it.

answered Jan 16 by Kirk Davis

Related Questions In Cloud Computing

+3 votes
3 answers

Is it possible to delete a API in AWS API Gateway?

Yes, it is possible to delete an ...READ MORE

answered Mar 27, 2018 in Cloud Computing by brat_1
• 7,080 points
674 views
0 votes
1 answer

Can we Use Api keys with AWS API Gateway?

There is no getting away here. When ...READ MORE

answered Apr 18, 2018 in Cloud Computing by hemant
• 5,750 points
32 views
0 votes
1 answer

AWS: What is an API Gateway in AWS?

Amazon API Gateway is a fully managed ...READ MORE

answered Jul 26, 2018 in Cloud Computing by Meci Matt
• 9,420 points
48 views
0 votes
1 answer
+2 votes
2 answers

Authenticated users with STS and API Gateway

RoleSessionName being an identifier for a defined ...READ MORE

answered Mar 27, 2018 in Cloud Computing by brat_1
• 7,080 points
119 views
+3 votes
6 answers

Are the S3 buckets in AWS, Region Specific?

Yes S3 buckets are region specific. When you ...READ MORE

answered Oct 16, 2018 in Cloud Computing by Rijo
1,659 views
+4 votes
3 answers

AWS S3 pricing - data transfer in/out

All traffic FROM mobile phones to S3 ...READ MORE

answered Oct 16, 2018 in Cloud Computing by anish
84 views
+3 votes
23 answers

What is an “Edge Location” in AWS?

Let us start with brief explanation to ...READ MORE

answered Apr 3, 2018 in Cloud Computing by brat_1
• 7,080 points
25,376 views
+4 votes
3 answers

AWS API Gateway with AWS WAF

Well that is not possible, Reason: API Gateway would ...READ MORE

answered Mar 27, 2018 in Cloud Computing by code_ninja
• 6,220 points
399 views
0 votes
1 answer

AWS Cloud9: Can we deploy only one Lambda function at a given time

Let us start understanding what happens when ...READ MORE

answered Apr 18, 2018 in Cloud Computing by code_ninja
• 6,220 points
93 views