Deploy MVC Application On Amazon EC2 Using Web Deploy

In my previous articles, we have learned how to set up an EC2 instance on AWS. In this article, you will learn how to deploy an MVC application from Visual Studio to Amazon EC2 using Web Deploy.

You can read the preview articles here.

Once your EC2 instance is running and you are able to connect RDP with all the required port settings, security group, and users; let’s start deploying a sample MVC application with Web Deploy from Visual Studio to an IIS Web Server running on Amazon EC2. We will see how to install the required tools and IIS on a virtual machine.

Let’s review some brief definitions.

What is Amazon EC2?

 
An EC2 instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure. AWS is a comprehensive, evolving cloud computing platform; EC2 is a service that allows business subscribers to run application programs in the computing environment.
 

What is Web Deploy?

 
Web Deploy (Web Deployment Tool) is a Microsoft tool that significantly simplifies the migration, management, and deployment of IIS web servers, web applications, and websites. You can install and configure Web Deploy as a third-party component on your Plesk-managed server.

Getting Started

The first thing is,  you have to add a rule in your security group which is used in your EC2 instance.

 

Rule protocol is Custom TCP Rule, the type is TCP, and port is 8172 with source anywhere.
 

Connect to Windows Server via Remote Desktop

Once the instance is created, select it in the EC2 Management Console and click on the "Connect" button. Follow the instructions to retrieve the administrator password and download the Remote Desktop File.

Remotely connect to the server instance using that .rdp file and enter your credentials.

Click on "Add roles and features".

Read the instructions and click "Next".

Select Role-based or feature-based installation and click "Next".

From the Server Selection tab, select a server from the server pool and select server name and click "Next".

Select the Web Server (IIS) and select Common HTTM Features. Then, select WebDAV publishing if not installed and from "Health and diagnostics", select the options given in the following screenshot.

From Performance (Static Content Compression, Dynamic Content Compression) and from Security (Request Filtering, Basic Authentication, Digest Authentication, and Windows Authentication).

Form Application Development (.NET Extensibility 3.5 and 4.6 and ASP.NET 3.5 and 4.6 and ISAPI Extensions, ISAPI Filters and WebSocket Protocol).

Form FTP Server tab, select FTP Service.

From Management Tool, select IIS Management Console, IIS Management Scripts, and Tools and Management Service.

Click "Next".

I am not selecting any features from this screen;  hit "Install".

So, we are done with the required installation part here. Now, let’s move to Web Deploy.

Install Web Deploy package

Go here to download the package and run the Microsoft Web Platform Installer.

Using the installer search field, find and select Web Deploy 3.6 and click "Add".

Click the "I Accept" button.

Wait until the package installs.

Click "Finish".

 

Create a sample MVC application

  • On the computer running Visual Studio, choose File > New Project.
  • Under Visual C# or Visual Basic, choose Web, and then in the middle pane choose either ASP.NET Web Application (.NET Framework) or (for C# only) ASP.NET MVC Web Application, and then click "OK".
  • If you don't see the specified project templates, click the "Open Visual Studio Installer" link in the left pane of the New Project dialog box. The Visual Studio Installer launches. Install the ASP.NET and web development workload.
  • Choose either MVC (.NET Framework) or Web Application (Model-View-Controller), and make sure that No Authentication is selected, and then click OK.
  • Type a name like TestAWSDeploy and click OK.
  • Visual Studio creates the project.
  • Choose Build > Build Solution to build the project.

Create a website on IIS

Type inetmgr in the Run window to open IIS.

Add a new website.

Give this website a name and a physical path.

Publish MVC Application

Right-click on the sample application and click "Publish".

Select IIS, FTP, etc. from the template to public app using Web Deploy or file transfer and click "Create Profile" button.

Enter your EC2 instance server name, website name (same name as IIS website), username and password, and Destination URL followed by hitting "Next" and wait until the website is published.

You will get the certificate error message; click the "Accept" button.

Select "Publish" option's properties and click "Save". So, your profile will be saved.

Now, you can see your profile there. It’s time to hit the "Publish" button.

Enter EC2 instance Username and Password and click "OK".

Wait until the site gets published and once you see the success message, you are done with publishing.

Now, open your published website. You will see your website running on Amazon AWS.

Note
Please make sure to open these ports in your security group if not opened already.

And, make sure that the Web Management Service is running.

Otherwise, you will see the following error message.

Conclusion

In this article, we have learned how to configure EC2 instance and install tools for Web Deploy and how to deploy an MVC application from local to Amazon AWS EC2 Server.


Similar Articles