This article tells you how to deploy your ASP.NET MVC web application in Azure cloud service using Visual Studio.
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 deploy and hosts your app through IIS
- Worker Role- Does not use IIS and runs your app standalone
In this article, we are going deploy our web application using Web Role.
Create Azure Cloud Service with web role using cloud template in Visual Studio
Create a new project -> select Cloud -> Azure Cloud Service from the available templates. If not, download the latest Azure SDK and install it.
Figure 1 - Selecting a cloud service template
Enter a project name and click OK. In my case, I named it as AzureCloudServiceDemo.
In the next wizard, select ASP.NET Web Role and click on OK. In my case, I have selected Web API project from the wizard.
Figure 2 - Select a Web Role
Figure 3
Once all is done, your solution will be loaded with the web application and cloud service project.
Run your application on local machine.
Result in Browser Figure 4 - Application from localhost
Publish the application
Right-click on the AzureCloudServiceDemo and select Publish. The "Publish Profile" wizard will be opened.
Figure 5 - Publish settings
Sign in with your Azure account credentials.
Now go to Setting- > create a new cloud service. In my case, I named it as CoreAppApi.
- Environment - > I set it as production, or else set it as staging and later, swap in the Azure portal for production release.
- Build Configuration- > Release
- Service Configuration- >Cloud
- Enable remote desktop so that you can access the VM
Once you enable the remote desktop, the "Create Account" wizard will be opened. Give the details and save it.
Figure 6 - Remote desktop connection Account settings
Diagnostic -> Enable the application insight to monitor the issues in VM.
Figure 7
Once all done, click on "Publish".
Get the URL from the deployment result and test it.
Figure 8
Figure 9
Çonnect to VM
Login to the Azure portal, go to newly created Cloud service and go to Overview -> click on the web role. It will list you the configuration of that instance. Get the remote desktop connection and connect to the VM.
Figure 10 - Instance information
Click on "Connect" which is highlighted in the above image to download the RDP. Sign in to VM using the credential which is configured while publishing the application.
Once VM is opened, go to IIS. You can see the application which is hosted.
Figure 11 - IIS in VM
Reference
https://azure.microsoft.com/en-in/services/cloud-services/
Conclusion
We have seen how to deploy a simple ASP.NET Web application in Azure cloud service using web role and connect to the VM where it is hosted. Will see more about scaling and worker roles of cloud services in my future articles.
I hope you have enjoyed this article. Your valuable feedback, questions, or comments about this article are always welcome.