How To Create AWS EC2 Instance And Host .NET Application With IIS

Today we will create an EC2 instance of Windows Server and see how we can enable IIS to host a .Net core application. So let us start with AWS.

What is AWS?

So in one line, AWS stands for Amazon Web Services and it is the cloud computing platform from Amazon, for more you can read here.

What is EC2?

EC2 stands for Amazon Elastic Compute Cloud (Amazon EC2) and it is a web service that provides various computing capacities in the cloud. It lets us create the desired computing environment quickly. For example, if you need a server up and running for you to test or deploy your application it will take only a minute or two to set up your server in EC2.

So let us create a virtual machine and host an IIS application. At first, you need to have an AWS account. if you're a student then there is an easier way to get an AWS account using the GitHub Student Developer Pack which you can check out here.

Step 1. Go to AWS and click on AWS Management Console under My Account then choose Root user or IAM user based on the description and enter your email.

AWS Management

Click on Next and then enter your password and click on Sign in.

Password

Step 2. After signing in you will see this screen under the compute click on EC2 then you will be presented with the below screen.

EC2

Click on the launch instance.

Launch instance

Step 3. Then choose your preferred server image, I want to install the Windows server so I will proceed with this.

Server image

Then I will choose the free tier.

What is the free tier now?

In this tier, for the first 12 months following your AWS sign-up date, you get up to 750 hours of micro instances each month. When your free usage tier expires or if your usage exceeds the free tier restrictions, you pay standard, pay-as-you-go service rates.

 AWS sign-up

Step 4. Click on Configure instance details -- I will leave everything default here.

Configure instance

Step 5. Click on next to add storage. The default provided storage is 30 GB you can add more as per your need.

Add storage

Step 6. Now click on the next to add a tag. A tag consists of a case-sensitive key-value pair. For example, you could define a tag with key = Name and value = Webserver. So I am adding a Windows Machine instance.

Webserver

Step 7. Click on next Configure Security Group.

Configure Security Group

Step 8. Then click on review and launch now.

Review

You will be asked to choose a key pair for authorization purposes. Choose to create a new key pair enter the name of your Key Pair and then click on download Key Pair.

You need to keep it safe.

Key pair

Click on view instance and you will see your instance running.

Instance running

Step 9. You will see the newly created instance is running and now you need to click on connect so that we will be able to interact with the Windows server. So click on connect and choose RDP client.

RDP client

Step 10. Now click on Download remote desktop file and after that click on Get password. You need to browse your keypar. pem file in order to get your password. Now open the file you have downloaded and put your password.

Remote desktop file

You must see your Windows server screen.

Step 11. Now we need to enable the IIS server for hosting our .Net core app. So for that please follow the steps.

Click on Add roles and features.

IIS server

Click Next,

Click next

Now choose Role-based or feature-based installation.

 Role-based

Choose server,

Choose Server

Install .Net

Install .Net

Click on next and wait for the installation to complete.

Installation complete

Step 12. Now you must see IIS then go to tools and choose IIS Manager.

 IIS Manager

Step 13. If you have your own application then.

  • Go to C:\ (C drive)
  • Go to intepub folder
  • Go to wwwroot folder and create a folder where we will be keeping our project publish files.

You can download one sample project here.

Now under your server, you must see sites. Right-click on.

Sites

and choose Add Websites. Give the name of your site and browser in the project folder in port 80 is used by IIS so give any other port like 8080 or you can give 80 also but you need to change the default port to something else and click ok.

Add Websites

Step 14. Now go to the Application pool and choose Right-click on your application and Basic Setting and set the .Net CLR version to No managed code and Managed Pipeline Mode to Integrated.

.Net CLR version

Step 15. Go to sites and Right-Click on your site choose managewebsite and click on Browse and now you will see your website up and running.

Browse

So this is how we can create a Windows server in AWS and host a .Net application also I have written how to host PHP and Node.js apps in an AWS EC2 instance. You can read it here.

Next, we are going to see how can we load balance these servers using HAPROXY. So stay tuned and stay safe.


Similar Articles