Monday, May 21, 2012

Cloud/Windows Azure- BootStrapper

In this article I would talk about the very basics of setting up an environment for developing a cloud application using Microsoft’s VS 2010 environment. I would also talk about few terminologies which are used in the world of cloud computing. This is a very basic discussion for developing cloud applications, probably I would go over to their details in upcoming posts.
Windows Azure which has become quite popular over the years is the robust and flexible cloud platform provided by Microsoft. Using azure we can build, deploy and manage our applications developed in any language, over vast and robust datacentres provided and managed by Microsoft. It is therefore actually important to understand what actually is “The Cloud thing” before we can understand Windows Azure.
The Cloud Buzz I was in a lot of dilemma to understand this “cloud”, struggling through many questions in mind why this is becoming so popular all of sudden? What exactly it is? I realized later this is really not a new concept if we look back into the earlier days of computing, there were large “job processing centres” where people use to come with their jobs for processing. These jobs were then submitted to huge mainframes and jobs were processed. In the same way big companies like Amazon, Microsoft had developed their large datacentres and offered those to people for their storage and computational needs. This whole concept in this new technology era is termed as “CLOUD”. With the advancement in internet and technology this Cloud is brought closer to the users. You can actually think of cloud as a huge cluster of servers and you can use those clusters for computing/storage or both. Based on above concept let me frame a definition for cloud, there are many definitions to it but I think of cloud as “A computational and storage platform which is scalable and can be used by many people at the same time depending on their demand, thus providing the organizations with a cost effective solution.” To understand the “bolds” in the above definition let me compare this with a traditional server based approach. When I say a server based approach it means for a xyz company their huge server(s) are residing on a nice datacentre.  Imagine there is a huge demand by millions of users across the globe and you would realize that your server(s) residing on the datacentre are not able to cope up with those requests. What you will do? Upgrade the hardware for the server, if you are falling short of data storage you would upgrade the database server, increase the RAM, memory (This whole up gradation in a datacentre environment can be painful in itself). Now that you have prepared yourself for such outbreaks, you realize that it’s a low month from a user perspective so your worthy upgraded hardware is sitting idle most of the time. Do you want such a scenario? Cloud computing and storage provides you an optimal solution to such scenarios. Clouds are scalable that means they can grow and shrink on demand. Since the cloud clusters can be used by many people at a time so their immense hardware and maintenance would not be a burden on a single user/company.

Cloud Models:  The whole cloud concept is based on 3 models
   1)  IaaS: With Infrastructure as a service the cloud provider provides a whole infrastructure like the DBMS, OS, Webserver firewalls setup etc.

             2) PaaS: With platform as a service you can create and setup your own platform on the cloud provider (Microsoft in this case). So for example you are going to add tables and data to SQL Azure on the cloud.
3) SaaS: You setup your application and its data on the cloud network. So your software is provided as a service on the cloud network.

To complete the theory related to cloud lets classify clouds into two main groups
      1)  Public cloud: This type of cloud is available to all the public and people can use this cloud network for computational and storage needs. Examples of such cloud service are: Microsoft, Amazon, and Apple. The concept behind this public cloud is it managed and maintained by individual providers so they are considered to be cost effective.
      2) Private cloud: This type of cloud is managed by individual organizations/companies and are supposed to be more secure but less economical.

Back to Windows Azure Too much of theory about cloud has already spoiled the article so let’s fly into the cloud provided by Microsoft i.e. “Azure”. As already discussed azure is the cloud platform provided by Microsoft. Let us have a look at the basic architecture of an Azure based application which we can develop using VS 2010.

Fabric controller: This is the kernel of a windows azure OS. I call this as the kernel because it monitors, maintains and provisions machines to host applications that we deploy on the cloud. It also manages the various devices through different service like the hardware load balancer.
Azure Networking: This comprises of the complete web of network which azure maintains.
RED Dog Front end interface: This layer communicates with the Fabric controller.
SQL Azure: This is the highly scalable cloud database management system which is based on SQL technologies.
Windows Azure storage: For cloud storage purposes windows azure provide three types of azure storage.
   a)BLOBS: Binary large objects such as video streams, images can be stored in BLOBS. Each BLOB has a capacity of 1TB. With BLOBS we have a concept of containers where a single container can have multiple BLOBS and we access these BLOBS through containers.
   b)Tables: Tables have the same concept of sql tables but they are represented differently in a windows azure environment. The rows are based on the concept of entities with each entity having a property column. Each entity in the table has a PartitionKey and RowKey they together make each row as unique. They are highly scalable and can hold large amount of data.
   c)Queues; They are used for reliable message delivery on the cloud.

Having talked about Windows Azure let’s look at the VS 2010 environment for creating a windows azure application. As stated earlier this article would explain you the environment and terminologies involved in creating an Azure application.
Just open your VS 2010 with “administrator privileges” (right click on VS 2010 and click on Run As-> Administrator).

Click on the Windows Azure Project (If you don’t have the Azure SDK installed VS 2010 would show “Install Windows Azure tools/SDK”. You need to have IIS7 or later to install this SDK).
When you click on the “Windows Azure Project” you will see the following box which is very important for understanding how a Windows Azure application is created.

In windows Azure we have the concept of “Role”. I can consider a Role as a VM/DLL on a cloud platform. It is this Role which makes the cloud application scalable. We see different types of role in the dialog box:
  a)ASP.Net Web Role which is the web UI on the cloud.
  b)ASP.Net Web Role MVC3 Role which is the MVC3 app on cloud.
The other important role is the Background processing service which is the worker role. Worker role can contain arbitrary .net code and it can communicate with the web role. Usually it has code which works in background or used for background processing.
So we can select one web role and one worker role for now.

When we click OK we get a nice populated solution explorer in our VS 2010. Let's dissect this.

The highlighted project (WindowsAzureProject1) is the actual cloud project. It contains the cloud service configuration and definition files (.csfg,.csdef). The definition files tells us which project is associated with the webrole, workerrole what are the service end points. You can view its XML to figure out its properties.
for understanding how a Windows Azure application is created.

Similarly we have service configuration files which have the different connection strings it specifies the connection string, the number of instances for each role. You must have also noticed that there are two service configuration files one for the local development and one for cloud. (When we say local the VS 2010 provides us a virtual cloud environment through the use of emulator).  Just look at the configuration file below. The number of instance for each role is the most important concept in developing cloud application.

Microsoft enters into an SLA that they can provide 99.95% reliability if there are at least two instances of each role. It is this property which makes the cloud application reliable, scalable. We can change the instance count to 2 but it requires VS 2010 SP1 which I don’t have now L. Let’s try running the application with 1 instance. We get the page up and running mine says “My first cloud app!”J. Notice in task manager that VS 2010 has started a cloud emulator.

Right click on this emulator and click “show compute Emulator UI”.

You will be presented with the following explorer.

Since there is just one web and worker role it is showing for webrole (0) the console trace being spited out.
If you click on the show storage emulator you will see the following screen. It is not useful to us for now since we have not stored anything on cloud. My next articles would gradually move to advance cloud development and would go into details of many more concepts.

I realize that this blog is less of practical stuff but we have to clear many concepts before we can dig deep into writing cloud applications. Still this has just toched the base of cloud application development.