Deploying Your First MVC Application On Microsoft Azure

What is Microsoft Azure?

Microsoft Azure is an open and flexible cloud platform that serves as a development, data storing, service hosting, and service management environment. Windows Azure provides developers with on-demand computing and storage to host, scale, and manage web applications on the internet through Microsoft data-centers.

Benefits of using Microsoft Azure

There are many benefits of moving on the cloud platform. A few of them are listed below.

  • Reduced cost of infrastructure

    Company does not need to invest in IT infrastructure as it can use the Azure service and pay only for the service that is actually being used.

  • Easy Maintenance

    There is no need to have any IT team to upgrade software and hardware. By using Azure, this can be done through Azure Portal.

  • Scalability

    If your application has gotten a tremendous response and you need to scale your application up, this can be done with a few clicks in Azure.

  • Reachability

    As application is already on the Internet, it allows users to access the application irrespective of their location and hardware configuration.

Deploying MVC application on Azure involves three steps.

  1. Creating an MVC application.
  2. Setting up Web app in Azure and downloading publish profile.
  3. Publishing your MVC application using publish profile.

Create an MVC application

Let’s start and create an MVC application with the help of Visual Studio. We will be using the default MVC website generated by Visual Studio and will not be doing any customization in the MVC website.

So, let's go ahead and create an MVC application (I am using Visual Studio 2013 for this tutorial).

Just click on "File" menu and select "Project" in sub menu.



On the next screen, select "ASP.NET Web Application".



Provide a name for your MVC application and then click "OK". The following screen will be displayed.



Just select "MVC" in the templates and click on "OK" button. This will make Visual Studio create a new MVC project and you will get the following screen.



Setting up Web App in Azure and downloading publish profile

Prerequisite


You will need credentials to log into Microsoft Azure portal. If you do not have Azure credentials, you can simply register on Microsoft Azure website using this link.

Go ahead and browse https://portal.azure.com in a web browser. This will bring you to the following page. As I already have an Azure account, it is displaying the following.



Once you are logged into Azure portal successfully, you will see the following screen.



To setup MVC application in Azure, please click on “+”>>Web+Mobile>>Web App.



Once you click on “Web App”, you will see the following screen.



We need to give the following information to configure our Web app.
  1. App Name

    This is a generic name of a web app, for example,  “firstmvcapplicationdeploy” in our demo. You can provide any name here but make sure that the name is not already used on Azure. You can verify it by watching a green tick mark in App Name textbox itself.

  2. Resource Group

    All the resources like web app, SQL db etc. should be put inside a Resource Group. Resource group helps in grouping all the resources used by an application. You can provide any name here.

  3. App Service Plan

    This will be used for pricing and helping Azure to deploy the app to the respective data centers which are near to your geographic location. (In this demo, I have created a new service plan “firstmvcapplicationdeploy” to “Central India” as it is near to my location).

Once you have provided the above settings, please click the "Create" button on the Web App blade (panel). It will force Azure to create your “firstmvcapplicationdeploy” application and will notify you once it is done. 

When Azure is finished creating your application, Azure will notify you that your web app is deployed successfully (This does NOT mean that our MVC application is deployed). Notification can be seen by clicking the bell icon in top bar on screen.



Once “firstmvcapplicationdeploy” is created, click on Resource Icon >> “firstmvcapplicationdeploy” >> Overview >> More and click on “Get publish profile”. This will download a published file named “firstmvcapplicationdeploy.PublishSettings” on your computer.



Publishing your MVC application using publish profile

Now, back in our MVC application, right click on the "HelloWorld" project and click on "Publish" menu.



On the Publish screen, click on “Import” button and import “firstmvcapplicationdeploy.PublishSettings” file downloaded from the Azure portal.



Now, click on “Publish” button. This will make Visual Studio compile your application in release mode and if everything is successful, VS will publish your application on Azure, using the publish profile we provided.



Once the MVC is on Azure, you can browse your application using firstmvcapplicationdeploy.azurewebsites.net URL. Every application on Azure is hosted as a sub-domain on azurewebsites.net.



Thank you readers for patiently reading this article.

Up Next
    Ebook Download
    View all
    Learn
    View all