Using ASP.NET based applications on AWS – part 1

AWS has a reputation of being “Microsoft” unfriendly, even arcane in general.  My impression is that this is certainly not true seeing the support they provide on the SDK level (.NET  NuGet packages), the possibility to host classic ASP.NET applications on Elastic Beanstalk (EB), publishing them from Visual Studio, even package and upload from your favorite build server.  There is additional windows server support through the use of the EB extensions which lets you install additional software like services, MSIs and so on. .NET is not the first citizen in the AWS world, that is true, though they made a lot of effort.

That being said, let’s see why .NET developers don’t have a worry and build a simple ASP.NET Web API and host it on EB.

Make sure you have an AWS free tier subscription and the AWS toolkit for Visual Studio installed.

Let’s log into the AWS console and create an EB application.

In the next screens, you choose web server environment like shown below.  You will need to create a key pair up front (under EC2 dashboard: Network and Security).

For example, in EU-West-1 region (Ireland) you can find it here.

Finally, you can launch your environment by clicking launch on the last screen.  This will take some time.

For the record, you can automate this on the command line by using the awscli, which can be installed through python-pip with “pip install awscli”.

In the meantime create an empty Web API project in Visual Studio and add a mundane controller with one action:

    public class DefaultController : ApiController
        public DemoData GetDemoData()
            return new DemoData { Field1 = "Hello", Field2 = "Elastic Beanstalk"};

    public class DemoData
        public string Field1 { get; set; }
        public string Field2 { get; set; }

In the meantime, the EB environment should be ready and you can deploy the web API from visual studio as follows:

As you can see, you could also have created a new application environment straight from Visual Studio, but here we choose to “Redeploy to an existing environment”. Click the demo app in the list and click next.

After choosing the .NET runtime and the application path you can click Next.

Check the “Open environment status window …” to see the deployment progress.  Hit Deploy!

After a short while, the package is deployed and you can test your online API by going to the URL specified on the EB console.

For example:

In my case browsing to //

Don’t forget to remove your EB environment/application when your finished (to avoid costs).


This was a beginner tutorial, there is much more to tell about EB.  In the following post, I will explain build packaging and how to add EB extensions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.