Book Image

Microsoft Windows Azure Development Cookbook

By : Neil Mackenzie
Book Image

Microsoft Windows Azure Development Cookbook

By: Neil Mackenzie

Overview of this book

The Windows Azure platform is Microsoft's Platform-as-a-Service environment for hosting services and data in the cloud. It provides developers with on-demand computing, storage, and service connectivity capabilities that facilitate the hosting of highly scalable services in Windows Azure datacenters across the globe. This practical cookbook will show you advanced development techniques for building highly scalable cloud-based services using the Windows Azure platform. It contains over 80 practical, task-based, and immediately usable recipes covering a wide range of advanced development techniques for building highly scalable services to solve particular problems/scenarios when developing these services on the Windows Azure platform. Packed with reusable, real-world recipes, the book starts by explaining the various access control mechanisms used in the Windows Azure platform. Next you will see the advanced features of Windows Azure Blob storage, Windows Azure Table storage, and Windows Azure Queues. The book then dives deep into topics such as developing Windows Azure hosted services, using Windows Azure Diagnostics, managing hosted services with the Service Management API, using SQL Azure and the Windows Azure AppFabric Service Bus. You will see how to use several of the latest features such as VM roles, Windows Azure Connect, startup tasks, and the Windows Azure AppFabric Caching Service.
Table of Contents (16 chapters)
Microsoft Windows Azure Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding messages to a queue


The CloudQueue class in the Windows Azure Storage Client Library provides both synchronous and asynchronous methods to add a message to a queue. A message comprises up to 8192 bytes of data. By default, the Storage Client library Base64 encodes message content to ensure that the request payload containing the message is valid XML. This encoding adds overhead that reduces the actual maximum size of a message. The Windows Azure SDK v1.3 added an EncodeMessage property to CloudQueue allowing a message, the content of which is already valid XML, to be sent without being Base64 encoded.

Each message added to a queue has a time-to-live property after which it is deleted automatically. The maximum, and default, time-to-live value is 7 days.

In this recipe, we will learn how to add messages to a queue.

How to do it...

We are going to create a queue and add some messages to it. We do this as follows:

  1. Add a new class named AddMessagesExample to the project.

  2. Set the Target Framework...