Programming Windows Azure
Sriram Krishnan
Copyright 2010 Sriram Krishnan
This book uses RepKover, a durable and flexible lay-flat binding.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc., Programming Windows Azure , the image of a dhole, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
O'Reilly Media
Preface
I hate the term the cloud . I really do. In a surprisingly short period of time, Ive seen the term twisted out of shape and become a marketing buzzword and applied to every bit of technology one can conjure up. I have no doubt that in a few years, the term the cloud will be relegated to the same giant dustbin for bad technology branding that the likes of SOA and XML-based web services are now relegated to. Underneath all that marketing fluff, though, is the evolution of an interesting trend. Call it the cloud or Something-as-a-Service it doesnt matter. The idea that you can harness computing and storage horsepower as a service is powerful and is here to stay.
As a builder of things, I love technology that frees up obstacles and lets me focus on what I want to do: create. The cloud does just that. Whether youre a startup or a huge Fortune 500 company with private jets, the cloud lets you focus on building things instead of having to worry about procuring hardware or maintaining a storage area network (SAN) somewhere. Someday, well all look back and laugh at the times when trying to run a website with reasonable traffic and storage needs meant waiting a few months for new hardware to show up.
My involvement with this book started in early 2009. Windows Azure had just come on the market and other cloud offerings such as Amazon Web Services and Googles App Engine had been out for some time. I saw a lot of people trying to grapple with what exactly the cloud was, and try to cut through all the marketing jargon and hype. That was no easy feat, let me assure you. I also saw people trying to wrap their heads around Windows Azure. What exactly is it? How do I write code for it? How do I get started? How do I do all those things I need to do to run my app? I hope to answer those questions in this book.
One of the problems about putting anything in print is that it will inevitably be outdated. I have no illusions that this book will be any different. As Windows Azure morphs over time in response to customer needs and industry trends, APIs will change. Features will be added and removed. To that end, this book tries to focus on the why more than the how or the what. Im a great believer that once you know the why, the how and the what are easy to wrap your head around. Throughout this book, Ive tried to explain why features act in a certain way or why certain features dont exist. The actual API or class names might have changed by the time you read this book. Thanks to the power of web search, the right answer is never far away.
This book is split into two halves. The first half digs into how Windows Azure works and how to host application code on it. The second half digs into the storage services offered by Windows Azure and how to store data in it. The two halves are quite independent and if you choose, you can read one and skip the other. The nice thing about Windows Azure is that it offers a buffet of services. Like any buffet, you can pick and choose what you want to consume. Want to host code on Windows Azure and host data on the same platform? Thats perfect. Want to use the Windows Azure blob service but want to host code in your own machines? Thats just as good, too.
Throughout this book, youll find tiny anecdotes and stories strewn around. Several times, they are only tangentially relevant to the actual technology being discussed. Im a big fan of books that try to be witty and conversational while being educational at the same time. I dont know whether this book succeeds in that goal. But when you see the umpteenth Star Trek reference, youll at least understand why it is in there.
How This Book Is Organized
The chapters in this book are organized as follows:
This chapter provides an overview of the cloud and the Windows Azure platform. It gives you a small peek at all the individual components as well as a taste of what coding on the platform looks like.
In this chapter, you dive under the hood of Windows Azure and see how the platform works on the inside. The inner workings of the Windows Azure hypervisor and fabric controller are looked at in detail.
It is time to get your hands dirty and write some code. This chapter gets you started with the Windows Azure SDK and tool set and walks you through developing and deploying your first application on Windows Azure.
In this chapter, you see how to build more advanced services. Core Windows Azure concepts such as service definition and configuration, web roles, worker roles, and inter-role communication are dealt with in detail.
A key part of Windows Azure is managing your service after you have finished writing the code. In this chapter, you see the various service management options provided by Windows Azure. The service management API is looked at in detail.
In this chapter, you learn how to run applications on Windows Azure that are not written in .NET. This could involve writing applications in C/C++ or running other runtimes such as PHP or Ruby.
kicks off the storage part of the book. This chapter delves into the basics of the Windows Azure storage services and provides a short overview of the various services offered. The REST API behind the storage services is looked at in detail.
This chapter looks at the blobs service offered by Windows Azure. It delves into how to use the blobs API, different types of blobs, and how to use them in common scenarios.
In this chapter, you learn about the queue service offered by Windows Azure. You see how to use queues in your services, and how to put messages in a queue and take them out.
A key part of Windows Azure is the ability to store massive amounts of structured data and be able to query it efficiently. The table service offered by Windows Azure is a great option to do just that. This chapter delves into tableshow to efficiently partition, query, and update your data.
In this chapter, you learn how to perform tasks that you are used to on other systems but may require some work on the cloud. This chapter looks at building full-text search on top of the Windows Azure table service and wraps up by looking at common modeling and performance issues.
This chapter happens to be one of my favorites in the book. It walks through the building of a secure backup system, built completely on open source tools and libraries. Along the way, it looks at various security, cryptography, and performance issues while designing applications with the cloud.