Deploy ASP.NET MVC Web Application In Cloud Service Using Azure Portal

Introduction

This article tells you how to deploy your ASP.NET MVC web application in Azure Cloud Service using Azure Portal.

Content

  • What is Azure Cloud Service?
  • Create Azure Cloud Service in Azure Portal
  • Create an application package
  • Upload package on Azure portal
  • Export the Azure Portal certificate
  • Start Deployment

What is Azure Cloud Service?

Cloud service comes under PaaS service model. Like in a web app service, we can deploy our web application in this service and moreover, it provides better control on the VMs for the users and we can install our own software by removing it.

There are two types of Cloud Service roles,

  • Web Role- Automatically deploys and hosts your app through IIS
  • Worker Role- Does not use IIS and runs your app standalone

Create an Azure Cloud Service in Azure Portal

Step 1

Log into Azure portal https://portal.azure.com

Step 2

Click on "Cloud service (classic)" from the left menu as shown in figure 1 or else, click on + icon and search for cloud service from the marketplace as shown in figure 2.

 
Figure 1 

 
Figure 2 

Step 3

Click on Create, give a DNS name, choose the respective subscription, resource group; the location, package, and certificate are right now optional, just skip these and click on "Create".


Figure 3

 
Figure 4 

Create a package

I have already created a cloud service project with web role in my previous article. Now, we are going to use same the project for deployment. The basic difference is, in my last article, I have explained how to deploy our web application directly from Visual Studio to Azure Cloud Service but in this article, I'm going to explain how to create an application package and deploy on Cloud Service using Azure portal.

From the project, right-click -> package as shown in figure 5. In the next window, choose "Cloud" as Service Configuration and "Release" as Build Configuration, as shown in figure 6 and click Package. It will create a package with application cloud service package file and the cloud service configuration file.

 
Figure 5 

 
Figure 6 

Upload package on Azure portal

Open the Cloud service which is created using the Azure portal. In Overview pane, click on "Upload" to upload the package.

 
Figure 7 

Give the deployment label name. In my case, I named it as aspnet_demo.

  • The package is from local.
  • The storage account is mandatory for deploying the package because the package needs to be stored before deploying in the cloud service.
  • Upload a Package – upload an application package from local system by browsing the file.
  • Upload a configuration - upload a cloud service package from local system by browsing the file.
 
Figure 8 - Naming deployment label 

 
Figure 9 - Select storage account

 
 Figure 10 - Uploading cloud service package 

 
Figure 11- Uploading cloud service configuration file 

Figure 12

Check "Deploy" even if one or more roles contain a single instance if you configured to one instance. This configuration details will be available in cloud service definition file.

Check "Start deployment". Once your package is uploaded, click OK to start the deployment process.

 
Figure 13

Oops, our deployment is failed because there is no certificate included. Let us export the certificate using Windows Azure Tools from the Certificate Manager.

Export the Azure Portal certificate

Open Certificate Manager using certmgr.

Go to Personal->Certificates-> right-click on Windows AzureTools -> All Tasks -> Export.

Figure 14

Check on "Yes", export the private key to include the key in the certificate, then check "Personal Information Exchange", and click Next. Set a password and save the file on the local system.

 
Figure 15 

 
Figure 16

 
Figure 17

Go to the Azure portal -> click on Cloud service and select recently created cloud service (CloudAppApi). In that, select certificate as shown in below figure and upload the file from local system.

Figure 18

Start Deployment

Once the certificate is uploaded, continue with uploading the package and deploy it as explained in the previous topic (upload package on the Azure portal).

After successful deployment, click on the site URL from Overview to check if the application is running on Cloud Service.

 

Yes, the site is up and running with cloud service.

I hope you have enjoyed this article. Your valuable feedback, questions, or comments about this article are always welcome.

Up Next
    Ebook Download
    View all
    Learn
    View all