In this article, we are going to see how to deploy as ASP.NET MVC application to the Windows Azure Cloud services from Visual Studio 2012 IDE. In our earlier article we have seen how to analyze and capture a Virtual Machine Image and store it to the Cloud VHD. ASP.NET MVC 3 gives a powerful, patterns and framework based way to build dynamic websites that enables a clean separation of data and the views and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, Test driven Development friendly development for creating sophisticated applications that use the latest web standards. ASP.NET MVC on windows Azure provides a greatest support with the web roles that are available to make the development much easier and quicker. Let us see the step-by-step process on how to develop an application and deploy the application directly to the Windows Azure Cloud Services.
Open Visual Studio 2012 IDE in administrator mode and create a new Windows Azure Cloud Project by Clicking on New Project and selecting Cloud template tab as shown in the screen below. Note to open the Visual Studio Integrated Development Environment (IDE) in administrator mode as Microsoft Windows Azure projects need to take some control over the emulators, which needs the administrator privileges.
Clicking on OK and proceeding to the next step, we can see a window with the list of available roles that can be used across different programming languages. Since in our example we are going to see how to develop an ASP.NET MVC3 app that will be deployed to the Microsoft Azure website, select the ASP.NET MVC3 web role and move it to the Windows Azure Cloud Services Solution to proceed to the next step as shown in the screen below:
We can see a new windows which the list of options that are required to configure the application, here we can select the application is going to be an Empty app, Intranet App or an Internet App. Since we are going to make it available over the internet we will select the application as Internet application and click on OK as shown in the screen below. If we need to create a unit test we can select the option that is available as a checkbox in the same screen.
We can see the application project is created and the list of files will be loaded to the solution explorer. Now we will make some small changes in the application to showcase the application that is designed for this sample. So make changes in the views and build the application to view it locally as shown in the screen below:
Now our next step is to start packaging and upload the application to the Windows Azure cloud services, to start with first right click on the application project and select the option Package. First we will package the application and upload the package to the Windows Azure Cloud Services using the available tools. Normally on creating a package, we will get two files namely a configuration file and a package file as shown in the screen below:
Clicking on Package option will get a small popup asking for the package configuration options like selecting the mode of the build configuration and the type of the service configuration to select based on our requirement as shown in the screen below:
After selecting the appropriate option click on Package will start preparing the package (Service and Configuration files), we can see the status of the package preparation at the output window of the Visual Studio 2012 IDE. After successful creation of the package we can see a folder will be opened with the 2 files created for the application. Basically the folder will be created in the bin folder of the application project under the build option mode; here we selected the Release version so the package files will be created in the Release folder as shown in the screen below:
Now we can see the package is ready to use, our next step is to publish the package to the Microsoft Windows Azure Environment. To start with login to the portal using the link www.windowsazure.com. On successful login select the option New Windows Azure Cloud Services as shown in the screen below. In the Windows Azure Cloud Services provide the valid Service name and select the appropriate region name and subscription to start creating the environment.
Now we can see the services are created and clicking on the service name, we can see the option to start uploading the package. Click on the upload production package will open windows where we need to enter the deployment package name and select the appropriate package (i.e. the package file and the service configuration file) as shown in the screen below:
Once all the files are selected click on proceed to process further, we can see the upload starts and it will take some time to provision based on the size of the package we deploy. Once the package is uploaded successful, we can see the environment ready and accessible as shown in the screen below:
To access the application navigate to the URL http://f5debugbrmvc.cloudapp.net/ and we can see our application online which is hosted on the Windows Azure Cloud environment. The URL can be fetched from the Dashboard of the application, which we uploaded as shown in the screen below:
Therefore, in this article we have seen how to upload an ASP.NET MVC application, which is designed and developed in Visual Studio 2012 IDE with the help of inbuilt packaging tools for Windows Azure.