Developing Cloud Applications using Microsoft Visual Studio 2010

Introduction

Cloud Computing is an infrastructure that enables you to develop and deploy your applications in the cloud, i.e., in remote servers. The most important benefits of using Cloud Computing Infrastructure include the following: reduced cost, scalability, flexibility and efficiency. Microsoft's Windows Azure platform is the Operating System for the Cloud and comprises a group of cloud technologies with each of them providing a specific set of services. This article presents an overview of cloud computing, its benefits and then discusses how you can develop cloud applications using Microsoft Visual Studio 2010.

Pre-requisites

To use the code examples illustrated in this article, you should have the following installed in your system:

  • Microsoft Visual Studio 2008
  • Microsoft Azure Tools for Microsoft Visual Studio

Alternatively, you can have Microsoft Visual Studio 2010 and Windows Azure Tools for Microsoft Visual Studio 2010.

What is Cloud Computing?

Cloud Computing is a buzzword these days. It may be defined as a phenomenon that promises to increase business agility by increasing the velocity with which applications are deployed and lowering the costs. Note that Cloud Computing is not a technology revolution. Rather, it is a business and process evolution. The Windows Azure platform is Microsoft's Cloud Computing Framework that provides a wide range of Internet services that are consumable from both on-premises environments and even the internet.

The Microsoft Windows Azure Services platform provides you the hosting platform and the necessary tools to develop applications that can reside in the cloud. It comprises of the following components:

  1. Microsoft Azure
  2. SQL Azure
  3. Microsoft .NET Services
  4. Live Services

Building Your First Cloud Service in Microsoft Visual Studio 2010

Microsoft Visual Studio 2010 comes packed with features aplenty that eases development of applications both for the desktop and the web. In this section we will explore how we can develop cloud applications using Visual Studio 2010. Visual Studio 2010 contains Windows Azure Tools that helps developers develop, debug and deploy applications and services that can reside in the cloud. The MSDN states: "The Windows Azure Tools and Visual Studio 2010 makes it easy to create, edit, configure, debug and deploy applications that run on Windows Azure. They allow you to leverage your existing skills with ASP.NET and with Microsoft Visual Studio." Reference: http://msdn.microsoft.com/en-us/magazine/ee336122.aspx

To create you first Cloud Service in Microsoft Visual Studio, follow these steps:

  1. Open Microsoft Visual Studio 2010 IDE
  2. Click on File->New Project
  3. Select Cloud Service as the project type
  4. Microsoft Azure - Select Cloud Service as the project type
    Figure 1

  5. Click on Enable Windows Azure Tools and click OK
  6. Click on Enable Microsoft Azure Tools and click OK
    Figure 2

  7. In the screen that comes up next, click on the "Download Windows Azure Tools" button

    In essence, you cannot start developing applications that can reside in the cloud using Microsoft Visual Studio 2010 unless you have the Windows Azure Tools for Visual Studio 2010 installed in your system. Once you have clicked on the button shown in the figure above, the download of the Windows Azure Tools for Visual Studio 2010 starts. You can see the progress in the figure that follows next.

    download of the Microsoft Azure Tools for Microsoft Visual Studio 2010
    Figure 3

    Note that before you install Windows Azure Tools for Visual Studio 2010 you should have IIS installed in your system. Once the download of Windows Azure Tools for Microsoft Visual Studio 2010 is complete, double-click on the .msi file to install it. The following figure shows the installation progress.

    Azure installation progress
    Figure 4

    When the installation of Windows Azure Tools for Visual Studio 2010 is complete, the following screen appears:

    installation of Microsoft Azure Tools for Visual Studio 2010 is complete screen
    Figure 5

    Note that you should run Visual Studio 2010 as an administrator. Now that Windows Azure Tools for Microsoft Visual Studio 2010 and the necessary components have been installed, you will get the necessary templates and runtime components that are needed to develop cloud applications--you need not wait to register for access to Azure cloud services and invitation tokens.



Developing Cloud Applications using Microsoft Visual Studio 2010

  • Now, follow the same steps (steps 1 to 3) as discussed earlier to create a Cloud Service in your Microsoft Visual Studio 2010 IDE.
  • Specify ASP.NET Web Role as the role for the Cloud Service. The default name of the role would be WebRole1, rename it to "MyWebRole" and click OK when done
  • [Figure 6.png]
    Figure 6

    You will see two separate projects in your solution. One of them is the Cloud Service project and the other an ASP.NET Web Role project. The Solution Explorer Window looks like as shown in the figure next:

    [Figure 7.png]
    Figure 7

    The Cloud Service project contains the necessary configuration information for hosting one or more role projects in the cloud environment. If you look at the Roles node for the Cloud Service project in the Solution Explorer Windows, you'll observe that there is only one entry--one role called MyWebRole. This implies that your Cloud Service would be hosting one role. You can also add more roles to your Cloud Service if needed.

    Also, you would see two XML configuration files named, ServiceDefinition.csdef and ServiceConfiguration.cscfg in the Solution Explorer Window. These files are used to define the necessary configuration to host one or more roles in the cloud.

    The ServiceConfiguration.cscfg file looks like as shown below:

      <?xml version="1.0"?>
      <ServiceConfiguration serviceName="MyCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
        <Role name="MyWebRole">
          <Instances count="1" />
          <ConfigurationSettings>
            <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />
          </ConfigurationSettings>
        </Role>
      </ServiceConfiguration>
    

    The content of the ServiceDefinition.csdef file is as follows:

      <?xml version="1.0" encoding="utf-8"?>
      <ServiceDefinition name="MyCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
        <WebRole name="MyWebRole">
          <InputEndpoints>
            <InputEndpoint name="HttpIn" protocol="http" port="80" />
          </InputEndpoints>
          <ConfigurationSettings>
            <Setting name="DiagnosticsConnectionString" />
          </ConfigurationSettings>
        </WebRole>
      </ServiceDefinition>
    

    Now, to run your application, set the Cloud Service as the startup project. When the Cloud Service runs, it would in turn start all the roles that it would be hosting. In our example, there is only one role named, "MyWebRole". So, once you start the Cloud Service, it would in turn start the MyWebRole project.

    And, you are done! You have successfully developed your first Cloud Application. To start the application, press F5. Here's what the output should be like:

    [Figure 7.png]
    Figure 7

    Summary

    Cloud computing is fast emerging as a popular platform for enterprises to leverage the features and benefits of shared infrastructure, lower costs and lower management overhead. It should be noted that the Windows Azure Platform can be used both by applications that reside and run in the cloud environment and also by applications that reside and execute out of the cloud environment, i.e., those that reside and run in the local systems. In this article we discussed the basic concepts of Cloud Computing and how we can develop applications for the cloud using Microsoft Visual Studio 2010 and Windows Azure Tools for Visual Studio 2010.

    Suggested Readings

    http://msdn.microsoft.com/en-us/magazine/ee336122.aspx
    http://visualstudiomagazine.com/articles/2010/04/01/using-visual-studio-2010.aspx
    http://www.microsoft.com/windowsazure/

    Related Articles





    About the Author

    Joydip Kanjilal

    Microsoft Most Valuable Professional, Author and Speaker. Featured in "MSDN Featured Developer of the Fortnight (India)" a number of times. Winner of Community Credit Awards at www.community-credit.com several times. Authored numerous books and articles in Microsoft .NET and its related technologies. Authored the following books:-- ASP.NET 4.0 Programming (Mc-Graw Hill Publishing) Entity Framework Tutorial (Packt Publishing) Pro Sync Framework (APRESS) Sams Teach Yourself ASP.NET Ajax in 24 Hours (Sams Publishing) ASP.NET Data Presentation Controls Essentials (Packt Publishing)

    Comments

    • There are no comments yet. Be the first to comment!

    Leave a Comment
    • Your email address will not be published. All fields are required.

    Top White Papers and Webcasts

    • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

    • In this webinar, IDC featured speaker Steve Conway, Vice President of High Performance Computing, will present an update on the global x86 HPC cluster market. The presentation will include IDC's five-year forecast for the medium- to large-scale technical computing and data analysis emerging markets by systems, processors and application middleware. Cray's featured speaker, John Lee, Vice President of Cray Cluster Advanced Technology Systems, will present the new Cray® CS400™ cluster series based on …

    Most Popular Programming Stories

    More for Developers

    Latest Developer Headlines

    RSS Feeds