BUILDING Hybrid APPLICATIONS in the CLOUD on WINDOWS AZURE
Total Page:16
File Type:pdf, Size:1020Kb
B UILDING BUILDING HYBRID APPLICATIONS IN THE CLOUD ON WINDOWS AZURE patterns & practices The IT industry has been evolving at a rapid pace; and with the advent Proven practices for predictable results H Y of the cloud computing the rate of evolution is accelerating significantly. B However, most organizations still have a lot of IT assets running in on- Save time and reduce risk on your RID software development projects by premises datacenters. A incorporating patterns & practices, BUILDING HYBRID We are in the middle of a transition between running everything on-premises Microsoft’s applied engineering PPLIC and hosting everything in the cloud. Hybrid is a term that represents the guidance that includes both production application that positions its architecture somewhere along this continuum. quality source code and documentation. A TIONS Hybrid applications span the on-premises and cloud divide, and bring with APPLICATIONS IN THE CLOUD The guidance is designed to help them a unique set of challenges. software development teams: IN This guide addresses these challenges by mapping Windows Azure features Make critical design and technology ™ T to specific scenarios encountered in the hybrid application design and selection decisions by highlighting H ON WINDOWS AZURE the appropriate solution architectures, E development. A case study of a fictitious company named Trey Research explains the challenges encountered in a hybrid application, and describes technologies, and Microsoft products C LOUD solutions using Windows Azure features such as Service Bus, Caching, Traffic for common scenarios Manager, Azure Connect, SQL Azure Data Sync, ACS, and more. Understand the most important ON concepts needed for success by The Trey Research Scenario W Introduction to the Guide explaining the relevant patterns and prescribing the important practices INDO Hybrid Challenge Scenarios Replicating, Distributing, and Synchronizing Data Authenticating Users and Authorizing Requests Get started with a proven code base Implementing Cross-Boundary Communication W Deploying Functionality and Implementing Business Logic and Message Routing by providing thoroughly tested Data in the Cloud S Maximizing Scalability, Availability, and Performance A Data synchronization and Reporting software and source that embodies Monitoring and Managing Hybrid Applications Microsoft’s recommendations ZURE Authenticating Users in Implementing Reliable Messaging and the Orders Application Communications with the Cloud The patterns & practices team consists ™ of experienced architects, developers, writers, and testers. We work openly Maximizing Scalability, Processing Orders in the Performance, and Availability Trey Research Solution with the developer community and in the Orders Application industry experts, on every project, to Scott Densmore ensure that some of the best minds in Monitoring and Managing Alex Homer the Orders Application the industry have contributed to and reviewed the guidance as it is being Masashi Narumoto developed. The guide is divided into two main sections. The first describes the specific John Sharp design decisions Trey Research made when designing their application. We also love our role as the bridge Hanz Zhang The second provides general guidance on typical scenarios and use cases between the real world needs of our encountered in each of the challenge areas. Together they will help you to customers and the wide range of find solutions for the challenges you will meet when developing your own products and technologies that hybrid applications. Microsoft provides. For more information explore: msdn.microsoft.com/practices Software Architecture and Software Development Building Hybrid Applications in the Cloud Building Hybrid Applications in the Cloud Scott Densmore Alex Homer Masashi Narumoto John Sharp Hanz Zhang 978-1-62114-013-9 This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. © 2012 Microsoft. All rights reserved. Microsoft, Active Directory, BizTalk, Hotmail, MSDN, SharePoint, SQL Azure, Visual C#, Visual Studio, Windows, Windows Azure, Windows Live, and Windows PowerShell are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners. Contents Contents v Foreword xi Preface xiii Who This Book Is For xiv Why This Book Is Pertinent Now xiv How This Book Is Structured xv What You Need to Use the Code xvi Who’s Who xvii Where to Go for More Information xviii Acknowledgments xix 1 The Trey Research Scenario 1 Integrating with the Cloud 1 The Challenges of Hybrid Application Integration 2 The Trey Research Company 4 Trey Research’s Strategy 5 The Orders Application 5 The Original On-Premises Orders Application 6 The Windows Azure Hybrid Application 7 How Trey Research Tackled the Integration Challenges 10 Staged Migration to the Cloud 12 Technology Map of the Guide 12 Summary 13 More Information 14 vi 2 Deploying the Orders Application and Data in the Cloud 15 Scenario and Context 15 Deploying the Application and Data to the Cloud 17 Choosing the Location for Data 17 Deploy All of the Data in the Cloud 18 Keep All Data On-premises 18 Deploy Some of the Data in the Cloud 19 How Trey Research Chose the Location for Deploying Data 19 Customer Data 20 Product Data 20 Order Data 20 Audit Log Data 21 Choosing the Data Storage Mechanism 21 Windows Azure Storage 21 SQL Azure 22 Alternative Database System or Custom Repository 23 How Trey Research Chose a Storage Mechanism for Data 23 Encrypting Data Stored in Windows Azure Storage and Databases 23 Synchronizing Data across Cloud and On-Premises Locations 24 Choosing a Data Synchronization Solution 24 SQL Azure Data Sync 24 Microsoft Sync Framework 25 A Custom or Third Party Synchronization Solution 25 How Trey Research Chose the Data Synchronization Solution 26 How Trey Research Uses SQL Azure Data Sync 26 Implementing a Reporting Solution for Cloud-Hosted Data 29 Choosing a Reporting Solution 29 SQL Server Reporting Services 30 SQL Azure Reporting Service 30 A Custom or Third Party Reporting Solution 31 How Trey Research Chose the Reporting Solution 31 How Trey Research Uses the SQL Azure Reporting Service 31 How Trey Research Makes Reporting Data Available to External Partners 32 Summary 36 More Information 37 3 Authenticating Users in the Orders Application 39 Scenario and Context 39 Authenticating Visitors to the Orders Application 42 Choosing an Authentication Technique 42 ASP.NET Forms Authentication 42 Claims-Based Authentication with Microsoft Active Directory Federation Service 42 vii Claims-Based Authentication with Windows Azure Access Control Service 43 Claims-Based Authentication with ACS and ADFS 44 Combined Forms and Claims-Based Authentication 45 How Trey Research Chose an Authentication Technique 45 How Trey Research Uses ACS and ADFS to Authenticate Visitors 45 Access Control Service Configuration 47 Handling Multiple User IDs 48 Authentication Implementation 48 Authentication with Windows Identity Foundation 49 ASP.NET Request Validation 52 Visitor Authentication and Authorization 53 The Custom Logon Page 54 Using a Custom Authorization Attribute 55 Customer Details Storage and Retrieval 56 Authenticating Access to Service Bus Queues and Topics 60 Summary 61 More Information 61 4 Implementing Reliable Messaging and Communications with the Cloud 63 Scenario and Context 63 Communicating with Transport Partners 67 Choosing a Communications Mechanism 68 Electronic Data Interchange (EDI) 68 Web Services (Push Model) 68 Web Services (Pull Model) 69 Windows Azure Storage Queues 69 Windows Azure Service Bus Queues 70 Windows Azure Service Bus Topics and Subscriptions 71 How Trey Research Communicates with Transport Partners 71 Sending Messages to a Service Bus Queue Asynchronously 75 Receiving Messages from a Service Bus Queue and Processing Them Asynchronously 77 Sending Messages to a Service Bus Topic 84 Subscribing to a Service Bus Topic 88 Receiving Messages from a Topic and Processing Them Asynchronously 90 Implementing Adapters and Connectors for Translating and Reformatting Messages 91 Correlating Messages and Replies 93 Securing Message Queues, Topics, and Subscriptions 94 Securing Messages 97 viii Sending Orders to the Audit Log 100 Choosing a Mechanism for Sending Orders to the Audit Log 100 How Trey Research Sends Orders to the Audit Log 101 Verifying Orders to Ensure Regulatory Compliance 104 Choosing Where to Host the Compliance Application 105 How Trey Research Hosted the Compliance Application 105 Summary 107 More Information 107 5 Processing Orders in the Trey Research Solution 109 Scenario and Context 109 Processing Orders and Interacting with Transport Partners 111 How Trey Research Posts Messages to a Topic in a Reliable Manner 112 Recording the Details of an Order 114 Sending an Order to a Service Bus Topic from the Orders Application 117 How Trey Research Decouples the Order Process from the Transport Partners’ Systems 131 Receiving and Processing an Order in a Transport Partner 132 Acknowledging an Order or Indicating that it has Shipped in a Transport Partner