Cloud Computing is a hot topic today and of course it is much more than just hosting of web application. Cloud computing allows you to dynamically scale your applications up and down as you need by using virtualised resources. To see the value let’s have a look at an example.
Let’s assume you start a new website and you have just the right amount of resources in your infrastructure – with enough flexibility for a moderate growth. Once you are past the early adopting phase you might need to buy more web servers. As the word spreads more and more users come to your site and you will increase the capacity of your database server. Now everybody tells his friends and family about this great website of yours. The traffic grows exponentially and therefore you have to redesign your database for scalability and eventually to buy more of everything. Unfortunately quite often it happens that after the initial hype the traffic goes back again before it settles at a certain level and now you have all that unused capacity in your data centres.
Now, hosting is of course a way how you can get around this but even then you will have to make the redesign in your databases and possibly your applications as well. Not to forget that you usually can’t just get an awful lot of resources without a pre-warning from your hosting provider. Now imagine an extreme example like a disaster management or information system. On normal days you will have moderate traffic but when the disaster strikes you have a huge peak in traffic. Particularly at that time when you need your application the most you might be flooded with requests and the service breaks down unless you have an awful lot of spare resources. On the other side if you have this huge amount of resources you are burning money every day that you don’t use them.
Cloud computing with capacity on demand is a cost efficient way out of this dilemma. While Virtual Earth is already a highly scalable cloud application we need to have a look at the code and data that you add for your application and we will do that by migrating your application to Windows Azure. Windows Azure is part of the Azure Services Platform. Think of it as an operating system for the cloud. Windows Azure provides virtual resources for computing and storage on which you can build your application but the real magic is in the Fabric.
The Fabric allows you distribute the application to as many resources as you need by just increasing the number of instances for your application either manually through a website or by uploading a new configuration-file.
Well that sounds simple enough and indeed it is simple but the storage does behave differently – particularly the table storage and we will have a closer look on how to create, build and publish a Virtual Earth Application on Windows Azure.
Creating and Publishing your first Virtual Earth Application for Windows Azure
There are lot’s of information for Windows Azure Developers. After you have signed up for an developer account you will probably want to download the Windows Azure SDK and – at least if you use the Visual Studio – also the Windows Azure Tools for the Microsoft Visual Studio. The former comes with a couple of samples of which we will use one later and the latter brings you templates for the Visual Studio. The Windows Azure SDK also comes with a development environment that emulates computing and storage services as well as the fabric on your local PC. A warning for those who are like me and always have to play with the latest technology: If you are using the Windows 7 Beta and use the January CTP of the Windows Azure SDK you won’t be able to run web-role projects through the local development fabric. You can however still run web-pages by right clicking them in the Solution Explorer and selecting ‘View in Brower’ from the context menu and as a matter of fact the application that I created for this blog post was developed with Visual Studio 2008 on Windows 7.
Once you have installed the Windows Azure SDK and Tools for Visual Studio bring up your Visual Studio and create a new project of type ‘Web Could Project’.
This will actually create a solution with 2 projects. The upper one contains the configuration and definition files. The lower one is the web-project that will hold our application.
Actually if you don’t need to access the storage or use worker-roles you can just just copy your existing web-page into the web-role project and publish it right away into Windows Azure. For starters I’ll use an ASP.NET AJAX application with an Accordion-Control from the ASP.NET AJAX Control Toolkit. The application uses a few Virtual Earth functions and imports GeoRSS-feeds from other internet services.
To publish the application right-click on the cloud service project and select publish from the context menu.
This will build the solution and package it for deployment. It will then open the Windows Explorer at the location of the package and the Windows Azure Developer Portal in your web browser:
Here you can navigate to an existing project or create a new one. Once you selected the project you can deploy it to a staging environment.
Now you can run the application …
…and test it.
Once you feel comfortable with your application you can swap staging and production environment and you’re live: