Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Windows Azuren step by step
Nội dung xem thử
Mô tả chi tiết
Windows Azure™
Step by Step
Windows Azure™
Step by Step
Roberto Brunetti
Published with the authorization of Microsoft Corporation by:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, California 95472
Copyright © 2011 by Roberto Brunetti
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any
means without the written permission of the publisher.
ISBN: 978-0-7356-4972-9
1 2 3 4 5 6 7 8 9 M 6 5 4 3 2 1
Printed and bound in the United States of America.
Microsoft Press books are available through booksellers and distributors worldwide. If you need support related
to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of
this book at http://www.microsoft.com/learning/booksurvey.
Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/
Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of
their respective owners.
The example companies, organizations, products, domain names, email addresses, logos, people, places, and
events depicted herein are fictitious. No association with any real company, organization, product, domain name,
email address, logo, person, place, or event is intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this book is provided without
any express, statutory, or implied warranties. Neither the authors, O’Reilly Media, Inc., Microsoft Corporation,
nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly
or indirectly by this book.
Acquisitions and Development Editor: Russell Jones
Production Editor: Teresa Elsey
Editorial Production: Online Training Solutions, Inc.
Technical Reviewer: Brian Keller
Indexer: Ginny Munroe
Cover Design: Twist Creative • Seattle
Cover Composition: Karen Montgomery
This book is dedicated to Barbara for her support in every important step of my life.
—Roberto
vii
Contents at a Glance
1 Introduction to Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Introduction to the Windows Azure Platform . . . . . . . . . . . . . . . 15
3 Creating a Web Role Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4 Windows Azure Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5 Tables, Queues, and Worker Roles . . . . . . . . . . . . . . . . . . . . . . . . 111
6 Windows Azure Operating System Details . . . . . . . . . . . . . . . . . 137
7 Building an AppFabric Solution . . . . . . . . . . . . . . . . . . . . . . . . . . 161
8 WCF Data Services and OData . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
9 Using SQL Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
10 Accessing Azure Services from Everywhere................ 259
11 Application Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
ix
Table of Contents
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
1 Introduction to Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Approaches to Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Infrastructure as a Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Software as a Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Platform as a Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Cloud Services Defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Long-Term Vision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Windows Azure as a PaaS Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Great Opportunity for Small Businesses . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Great Opportunity for Big Businesses . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Windows Azure and Cloud Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Introduction to the Windows Azure Platform . . . . . . . . . . . . . . . 15
The Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Service Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Windows Azure Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The Worker Role . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Virtual Machine Role . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Windows Azure AppFabric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The Service Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
The Access Control Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
SQL Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
What do you think of this book? We want to hear from you!
Microsoft is interested in hearing your feedback so we can continually improve our
books and learning resources for you. To participate in a brief online survey, please visit:
microsoft.com/learning/booksurvey
x Table of Contents
3 Creating a Web Role Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Software Development Kits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Windows Azure Tools for Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Web Role Project Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
The Cloud Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Deployment to Windows Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Configuration and Upgrading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Service Definition File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Role Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4 Windows Azure Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Local Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
The Windows Azure Storage Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Windows Azure Management Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Blob APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5 Tables, Queues, and Worker Roles . . . . . . . . . . . . . . . . . . . . . . . . 111
The Table Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
The Queue Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
6 Windows Azure Operating System Details . . . . . . . . . . . . . . . . . 137
Live ID, Subscriptions, and Billing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Affinity Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Content Delivery Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Table of Contents xi
7 Building an AppFabric Solution . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Windows Azure AppFabric Components . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Service Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Direct Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
HTTP for Management URI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
8 WCF Data Services and OData . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
The Astoria Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
WCF Data Services (ADO.NET Data Services) . . . . . . . . . . . . . . . . . . . . . . . . 194
The Building Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
WCF Data Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Query and Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Filtering, Sorting, and Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
WCF Data Service Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
The .NET Framework Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Security Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
9 Using SQL Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
SQL Azure Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
SQL Azure Database Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Database Server Creation in the Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
SQL Azure Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
SQL Azure Relational Engine Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Existing Database Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
SQL Azure Migration Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
xii Table of Contents
10 Accessing Azure Services from Everywhere................ 259
Creating the Storage Account Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Accessing the Storage Account from PHP . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Using HTTP and REST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
11 Application Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Characteristics of a Multitier Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The Data Access Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
The Service Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
xiii
Acknowledgments
A book is the result of the work of many people, but usually only the author name appears
on the cover.
First, I want to thank Vanni Boncinelli for his effort in reviewing all the chapters for both technical aspects and linguistic troubles. This is my first English-written book. Without him, the
editor would have rejected all the chapters.
I also want to thank Russell Jones for his patience in responding quickly and precisely to all of
my rookie questions and for supporting me from the beginning of this writing.
Many thanks go to Brian Keller: he has reviewed not only the text but every line of code two
times, because during the writing process Microsoft released the SDK 1.3, which was significantly different from the previous version around configuration and the Visual Studio IDE
add-in. Brian also had to re-review all the portal screenshots, because the Windows Azure
user interface was completely redesigned in Silverlight as of January 2011.
One of the most important people to thank is Victoria Thulman, who guided me in the process of copyediting all the chapters. Her patience with my mistakes and incorrect assumptions was immeasurable.
Gabriele Castellani and Giuseppe Guerrasio wrote the foreword and have supported me since
2008, when Microsoft first announced Windows Azure at PDC 08.
Fabio Santini and Mario Fontana have given me the opportunity to work with many Italian
Microsoft partners and with a wide range of application scenarios: you can find those experiences reflected in many of this book’s pages.
Last, but not least, thanks to Paolo Pialorsi, who introduced me to Russell Jones one year ago.
Now, the book is complete: thanks again to all of you.