Demystifying Azure Cloud Services: Cloud Service or WebApps? – Part 2
I have noticed that there is a general sense of mystery around Azure Cloud Service. Some equate it to Cloud Services in general while others get confused with the relation of Azure Cloud Service and Virtual Machines while some one else gets confused about using Azure Web Apps (formerly Websites) with webjobs over Azure Cloud Service. If you have been in a similar dilemma as I have been in the past, I will try and clarify the confusion and get you started on Azure Cloud Service through this tutorial series.
In Part 1 of this tutorial I covered an overview of some of the misconceptions that people have about Azure Cloud Services in general. From now, each subsequent part will demystify or inform how Azure Cloud Services are related to other services present in Azure. This post is about Azure WebApps.
Yes, you can develop and host websites using Azure Cloud Services as well as Azure WebApps ( a part of Azure App Services now). And yes, both are Platfrom as a Service (PaaS) offerings. In the spectrum of PaaS offerings, there is a difference in the amount of control that is given to you. If you want more granular control, you would want to look into Azure Cloud Service where as if you want just hosting services, you should look into Azure WebApps. Lets delve into this a little deeper to understand the functionality of each and how they differ.
There is enough documentation about Azure WebApp and I will not delve into the details of this but will position a comparative approach. Azure WebApps (AWA) is a PaaS solution to develop websites. Within AWA, there are a number of open source, CMS, blog, e-commerce frameworks available as templates that you can directly use to develop your website. You can also take advantage of scaling, load balancing, continuous deployment using Git, Github and have multiple deployment slots such as staging and production slots. In short, all your web development and hosting needs can be accomplished using WebApps.
However, lets get under the hood and understand what is happening. The diagram below is taken from Microsoft Azure Websites: Quick-and-Easy Hosting as a Service. The article explains in detail how this works. Just to keep it brief, the idea is that AWA is built on the PaaS platform of Azure – kind of an additional layer of abstraction to provide a PaaS which is built on PaaS. As you can see, it internally uses stateless worker roles, blobs and relational data bases.
It is important to understand that in AWA, you do not need to care about or worry about all these details. It is managed and taken care of internally. All you need to do is design and develop, deploy and scale your webapp as per need. This is the best option for you to get started, host an existing website, migrate another website to this scalable platform which also features near instant deployments. You can run background processes using Azure Webjobs and easily integrate databases with your websites. You can essentially do everything you want with Azure WebApps but if your webapp is dependent on the environment hosting it, in that case Azure WebApp may not be your first choice.
Azure Cloud Service for WebApps using WebRole
Now, let us look at Azure Web Roles. As I had explained in part 1, Azure had started with the notion of Cloud Services which was synonymous to hosting services. Web Roles were used to host websites which were essentially compute stateless instances. Worker Roles on the other hand were used to process background processes for an application. Hence, web roles were designed to be the front end, taking care of user interaction while worker roles takes care of the backend tasks. From an architectural point of view, Web roles were supported on Windows Server instances with IIS installed as they hosted the website, where as Worker Roles were supported by Windows Server instances without IIS. The communication between them was accomplished using Queues or Service Busses which I will cover in detail in subsequent posts as a part of this tutorial.
Hence, you could think of Azure Cloud Service to be providing you with all the features that Azure WebApps provide. How does it differ? Well, by the virtue of using Web and Worker roles, you still have some control over these instances. You can remote into these instances, define startup tasks for these instances and also define complex network integrations using Cloud Services. But keep in mind, what you gain in control and flexibility, you lose in speed of deployment and additional management overhead. There is always this tradeoff.
There is a third option to host websites on Azure and that is by using pure Infrastructure As a Service (IaaS) in the form of Virtual Machines where you install your environment to deploy your website and then host / deploy your website. But this is in the other end of the spectrum which gives you complete control and flexibility, but then again this is at the cost of time to deploy and added overhead of management. Azure AppService, Cloud Services and Virtual Machines comparison provides a pretty detailed comparison of the various services to host websites on Azure. It also lists out typical scenarios and maps service to scenario which is very helpful and does help understand the concept well. In the next post I shall cover Virtual Machines and Cloud Services and how they are related. Stay tuned and share your Azure stories with me @AdarshaDatta.