Published: 22 March 2017
The reason why I started looking into this was because I wanted a dead simple hosting solution for GeoToast.
And yeah, it has been a while since I have written about GeoToast. I spent a month in Japan, and sightseeing was higher on my list of priorities than coding…
AWS Lambda is the serverless product offered by Amazon Web Services. Serverless does not mean that there is no server involved - obviously there is - but just that managing servers, scaling, etc is not something that you need to worry about.
What you need to worry about (as programmer) is writing the code that executes the logic. You can then deploy it to a serverless environment such as AWS Lambda and it will take care of scaling etc. Some of the other offerings available are Azure Functions, Google Cloud Functions and also Webtask.
The other advantage is that serverless environments only charge you for the time your code takes to execute. So if you have a small POC you want to develop (like I do with GeoToast), this is ideal as you do not have to worry about paying for a server which sits idle 99% of the time.
I have only started playing around with AWS Lambda recently, but from what I can see so far there are basically 3 models which you can use when developing AWS Lambda functions using .NET Core and C#.
You can also read more about this model in Deploying Lambda-based Applications.
ASP.NET Core app as Serverless Application. This is a variant of the model above, but in this instance your entire exiting ASP.NET Core application is published as a single Lambda function. This then utilizes the API Gateway Proxy Integration to forward all request coming through API Gateway to this Lambda Function.
The Lambda function then hands the request off to the ASP.NET Core pipeline. So you have all the middleware you love at your disposal.
This means that you basically have the normal ASP.NET Core request pipeline, but instead of IIS/Nginx and Kestrel, you have API Gateway and Lambda. So instead of this:
You have this:
In the coming blog posts I will dive deeper into each of these.
So I guess another question is why I am using AWS Lambda and not the offerings from Microsoft, Google or Auth0’s own WebTask? Well, for a couple of reasons which are true at the time of writing this blog post:
I recommend watching this video first as it gives a great overview of AWS Lambda, the C# and Visual Studio support for AWS Lambda as well as the 3 programming models I discussed above.
Also stay tuned, as I plan to do more posts on C#, .NET Core and Lambda in the future.
PS: If you found this content valuable and want to return the favour, then please feel free to ☕ buy me a coffee ☕
Are you struggling to stay up to date with all that is happening in the ASP.NET world?
I publish a weekly newsletter with all the best ASP.NET related news and blog posts of the previous week
Sign up with your email address below to get it delivered to your Inbox every Friday!