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

Today we are going to create an EC2 instance of Windows Server and we will see how can we enable IIS for hosting 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 compute capacity 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 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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
Click on next and then enter your password and click on Sign in.
How To Create AWS EC2 Instance And Host .NET Application With IIS
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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Click on launch instance.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 3
 
Then choose your preferred server image, I want to install the Windows server so I will proceed with this.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 4
 
Click on Configure instance details --  I will leave everything default here.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 5
 
Click on next to add storage. The default provided storage is 30 GB you can add more as per your need.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
Step 7
 
Click on next Configure Security Group
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 8
 
Then click on review and launch now.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
You will be asked to choose a key pair for authorization purposes. Choose to create a new key-pair and enter the name of your Key Pair and then click on download Key Pair.
 
You need to keep it safe. 
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Click on view instance and you will see your instance running
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
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.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
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 
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Click Next 
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Now choose Role-based or feature-based installation
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Choose server
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Install .Net
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Click on next and wait for the installation to complete.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 12
 
Now you must see IIS then go to tools and choose IIS Manager
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
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 the project folder and in the 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's port to something else and click ok.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 14
 
Now go to the Application pool and choose Right-click on your application and Basic Setting and set .Net CLR version to No managed code and Managed Pipeline Mode to Integrated.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
 
Step 15
 
Go to sites and Right-Click on your site and choose managewebsite and click on Browse  and now you will see your website up and running.
 
How To Create AWS EC2 Instance And Host .NET Application With IIS
So this is how we can create a Windows server in AWS and host .Net application also I have written how to host PHP and Node.js app 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