Windows Azure is Microsoft’s application platform for the public cloud. This post describes the most important basic principles you must know beforehand.
The main thing that we do, as developers, is to write applications. Eventually, this code has to be executed. Windows Azure offers a platform that you can use to execute your applications, by means of three execution models:
- Virtual machines: it is possible to create virtual machines on demand and run your applications in them – this is also referred to as Infrastructure as a Service (IaaS). These machines are hosted for you in the cloud; which means they will always be accessible by you from anywhere, and you have total control over them. There are several images you can use, from Windows Server 2008 R2 to Linux.
- Web sites: if you have a web application (which may be static HTML, or an open source application like Drupal, WordPress, Joomla, or written in PHP, ASP.NET…), this model is most likely the one you need. It gives you a managed web environment in IIS to host your web application. Most of the administration is done for you, so that you can focus on what’s important: keep your web application up and running. As traffic increases, you can add more instances that are then load balanced.
- Cloud services: also known as Software as a Service (SaaS), this model gives you the flexibility to install arbitrary software (something that the web sites model doesn’t offer), without having to handle many aspects of reliability and administration yourself (as you have to do with the virtual machines model) – Windows Azure itself manages all of these things. In this model, you can choose between two roles: web and worker. The main difference between the two is that an instance of a web role runs IIS, while an instance of a worker role does not.
Which model you need depends on the problems you are trying to solve:
- If you need the most general solution with total control, use the virtual machines model; but remember that you are responsible for its administration.
- If you have a simple web site with little administration, use the web sites model.
- If you need more administrative access; have a multi-tier application with different layers for business and data logic; need staging and production environments; need to use networking technologies like virtual network, connect or traffic manager; or use remote desktop to connect to the virtual machine, you should use the cloud services model.
If no single execution model is right, you could even combine models.
As you might notice, it seems there is not a lot of difference between the web sites model and the cloud services model with web role. The main difference is scalability: the web sites model is limited in the amount of instances you can set up.
In most cases the applications we write need to store data. Of course we could set up a vitual machine and provide everything needed for data access. Of course, this means that we also have to manage all of it ourselves.
To make life easier, Windows Azure provides three data management options that are largely managed for you:
- SQL database: if you need relational storage, with transactions, and concurrent data access by multiple users with data integrity, this is the option to choose. You can use tools like SQL Server Management Studio to manage your data, and use your favorite data access technologies like Entity Framework.
- Tables: use this if you need fast access with simple queries to potentially large amounts of typed data. This basically is a key/value store.
- Blobs: use this if you need to store unstructured and large binary files.
To host your applications and store your data, Windows Azure runs in several datacenters spread across the United States, Europe, and Asia. Somehow you have to choose what data centers you want to use and how to connect to it:
- Virtual network: if you already have your own data center, you could extend it with Azure data centers using a virtual network, so that the public cloud is like an extension of your own datacenter – and appears to be on your own network. You could then easily add or remove virtual machines, depending on the power you need.
- Connect: use this if you want to connect a Windows Azure application to the existing infrastructure of your organization, for example, use an existing database that is on one of your own servers.
- Traffic Manager: if your application is used by users all over the world, you can use connect to intelligently assign users to application instances – being the ones most close to them so that response times are low, or if this data center is overloaded, automatically route the request to the second best one.
If you have a number of applications running, you typically need a way so that these applications can interact with each other. For this, Windows Azure provides:
- Queues: typically used to handle communication within the same Cloud Services application: one application places a message in a queue, and that message is eventually read by another application. A typical usage is a web application (configured as a cloud service web role) that sends a message to a component (configured as a cloud service worker role), so that this component can execute a task asynchronously. This makes it easy to scale, as you can change the number of web and worker roles as is needed.
- Service bus: the goal of Windows Azure Service Bus is to let applications running pretty much anywhere (in and outside the cloud) exchange data. This is not the same as queuing, because it provides a publish-and-subscribe mechanism: applications subscribe to certain events they are interested in, which means it’s more like a one-to-many communication. This approach encourages loosely coupled interactions between applications.
In most cases applications tend to need the same data over and over, and so this is where caching is important, because it holds a copy of that data closer to your application instead of having to retrieve it every time. Windows Azure provides:
- In-Memory Caching: accessing frequently used data stored in memory is very fast, and so this caching provides you with an in-memory cache to speed up your application. This cache can be distributed.
- CDN: Content Delivery Network is a caching mechanism that you can use if your users are spread all over the world and you have large blobs that need to be cached. In fact, they are replicated to other data centers.