■ INTRODUCTION xxiv • Exercise 6-1: Creates a console-based .NET service host to host a WCF service using relay bindings. • Exercise 6-2: Demonstrates how two applications can run behind firewalls and be connected directly through the cloud using relay hybrid connection mode. • Exercise 6-3: Uses .NET Service Bus to create an event-driven distributed Windows application system. A controller Windows application posts relay events to control another Windows application. • Exercise 6-4: Builds a .NET Service Bus QueueClient wrapper class, that provides an easy way for you to integrate the .NET Service Bus queue access in applications. Chapter 7: Windows Azure .NET Services—Workflows As you’d expect, Windows Azure works with workflows, which I examine in this chapter. • Exercise 7-1: Hosts a workflow service in the Azure cloud environment. • Exercise 7-2: Coordinates workflow services using HttpWebRequest. Chapter 8: SQL Azure As this book was nearing completion, Microsoft replaced SQL Data Services with SQL Azure. • Exercise 8-1: Creates a data-driven, XML application to work with the SQL Azure database services. Chapter 9: Deploy Windows Azure Applications to Production This chapter does not contain any exercises but covers how to deploy and manage your applications to the cloud. Appendix The appendix contains the specification Windows Azure blob storage and details of the Azure Services Management Tools. Downloading the Code The source code for this book is available at http://www.apress.com or http://www.softnetsolution.net/Apress/SourceCodeDownLoad/. ■ INTRODUCTION xxv ■ Note All code used in this book is designed for proof of concept and could potentially be used. However, the code has to be optimized and fine-tuned before you can use it in an application. It is especially important to add data-validation and error-handling code. Contacting the Author Henry Li can be contacted via e-mail at yinghong@softnetsolution.net or via regular mail at SoftnetSolutions, Inc., 192 NE 74th Ave., Hillsboro, OR 97124. You can visit the web site of SoftnetSolutions at http://www.softnetsolution.net. All your comments and feedback are appreciated. C H A P T E R 1 ■ ■ ■ 1 Create Cloud Table Storage An application, either on-premises or cloud-based, should use a kind of storage. For on-premises applications, the storage can be either local or remote. Storage on the cloud platform comes in a different style. It is hard to require a development team or an organization to provide generic, reusable data schemas for remote storage. The following list contains some items to pay attention to when switching from traditional relational data structure design to cloud table storage. • The data structure for cloud remote storage should be as simple as possible. The data model exposed to the outside world must be straightforward. The objects generally should be a set of binary bytes stored as buckets in clouds. Applications create, read, and delete objects in buckets. If an object needs to be updated, delete it and replace it with an object with updated values. This is how the cloud platform service changed to meet the Internet’s scalability requirements. The simpler the data structure, the better the performance will be for multiple Internet instances to access cloud data storage concurrently. Since storage in the remote cloud is so cheap, for an organization to scale up will be not an issue at all. The organization needs to simply increase the instance number from the configuration file. • You should be aware when migrating from on-premises storage to the cloud platform that if you have a relational data structure, then you will be responsible for managing the constraints between the data storage entities, because the cloud storage tables are not relational. This may be a challenge and the price you have to pay for using cloud storage. This is a new topic that .NET developers to have to face. In the cloud, the application can access its data from anywhere at any time and store any amount of data for any length of time. Azure storage provides a rich set of data abstractions in the following three aspects: • Blob storage, usually used to store data of large size. • Table storage that provides structured storage for applications. However, table storage is not relational data storage. Since table storage is in the cloud environment, a relational structure is not allowed. • Queue storage that provides asynchronous work dispatch to enable service communication. CHAPTER 1 ■ CREATE CLOUD TABLE STORAGE 2 Azure Table is the structured storage provided by the Azure platform. It supports massively scalable tables in the cloud, with capability to support up to billions of entities and terabytes of data. Depending upon the traffic demand, the storage will efficiently scale up by automatically spreading to thousands of servers. Azure table storage supports the Language Integrated Query (LINQ) extensions for .NET 3.0 or later versions, ADO.NET Data Services, and representational state transfer (REST), which allows applications developed using non NET languages to access table storage via the Internet. There is no limit on the number of tables and entities or on the table size. There is no need for table storage developers to handle the data access transactions, optimistic concurrency for updates, and deletes. Also, there is no need for developers to worry about performance, since cloud storage is highly scalable. Especially for long queries or queries that encounter a time-out, partial results will be returned and the unfinished queries can be continued with a return continuation token. In this chapter we are going to look at cloud data storage in detail. We’ll cover • The table storage specification • Azure development storage, which allows us to test cloud storage on the local machine • Creating cloud data storage and all the issues surrounding moving your data into the cloud The Table Storage Specification To access Azure storage you must use a valid account. When a new Azure storage account is created using the Windows Azure portal web interface, a 256-bit public shared key will be sent to you via e-mail. Usually it takes about couple of days for processing. The secret key must be passed as one of the parameters when initializing storage table access. The access will be authenticated based on the secret key. Authentication is required for each request to table storage. When REST is used to access table storage, the account name is part of the host name in the URL string. The URL is constructed with the format of http://<accountName>.table.core.windows.net. An example of an account can be found from DevelopmentStorage.exe.config of the Windows Azure SDK. The following are the key parts of the specification: • Table: A table contains a set of entities. Table names are associated to the account. There is no limit on how many tables an application may create within a storage account. • Entity: An entity can be understood as a row in cloud table storage, which is the basic data item stored in a table. An entity has a set of properties. • Property: A property can be understood as a value being held in an entity. The name for a property is case-sensitive. A rich type set is supported for property values, as Table 1-1 shows. . Service Bus to create an event-driven distributed Windows application system. A controller Windows application posts relay events to control another Windows application. • Exercise 6-4: Builds. integrate the .NET Service Bus queue access in applications. Chapter 7: Windows Azure .NET Services—Workflows As you’d expect, Windows Azure works with workflows, which I examine in this chapter format of http://<accountName>.table.core .windows. net. An example of an account can be found from DevelopmentStorage.exe.config of the Windows Azure SDK. The following are the key parts