In Windows Azure
Total Page:16
File Type:pdf, Size:1020Kb
Building Real-World Cloud Apps with Windows Azure Tom Dykstra Rick Anderson Mike Wasson Summary: This e-book walks you through a patterns-based approach to building real- world cloud solutions. The patterns apply to the development process as well as to architecture and coding practices. The content is based on a presentation developed by Scott Guthrie and originally delivered at the Norwegian Developers Conference (NDC) in June of 2013. Many others updated and augmented the content while transitioning it from video to written form. Category: Guide Applies to: Windows Azure Web Sites, ASP.NET, Visual Studio, Visual Studio Online, Windows Azure Active Directory, Windows Azure SQL Database, Source: ASP.NET site (source content) E-book publication date: January, 2014 1 Copyright © 2014 by Microsoft Corporation 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. 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, 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. 2 Table of Contents Building Real-World Cloud Apps with Windows Azure ......................................................................... 1 Table of Contents .......................................................................................................................................... 3 Introduction .................................................................................................................................................. 7 Intended Audience .................................................................................................................................... 7 Cloud development patterns .................................................................................................................... 7 The Fix it sample application .................................................................................................................... 9 Windows Azure Web Sites ...................................................................................................................... 13 Summary ................................................................................................................................................. 16 Resources ................................................................................................................................................ 16 Automate Everything .................................................................................................................................. 17 DevOps Workflow ................................................................................................................................... 17 Windows Azure management scripts ..................................................................................................... 18 Environment creation script ................................................................................................................... 18 Deployment script ................................................................................................................................... 28 Summary ................................................................................................................................................. 30 Resources ................................................................................................................................................ 31 Source Control ............................................................................................................................................ 32 Treat automation scripts as source code ................................................................................................ 32 Don’t check in secrets ............................................................................................................................. 32 Structure source branches to facilitate DevOps workflow ..................................................................... 33 Add scripts to source control in Visual Studio ........................................................................................ 35 Store sensitive data in Windows Azure .................................................................................................. 39 Use Git in Visual Studio and Visual Studio Online ................................................................................... 42 Summary ................................................................................................................................................. 50 Resources ................................................................................................................................................ 51 Continuous Integration and Continuous Delivery ...................................................................................... 52 Continuous Integration and Continuous Delivery workflow .................................................................. 52 How the cloud enables cost-effective CI and CD .................................................................................... 53 Visual Studio Online ................................................................................................................................ 53 Resources ................................................................................................................................................ 54 Web Development Best Practices ............................................................................................................... 56 3 Stateless web tier behind a smart load balancer .................................................................................... 56 Avoid session state.................................................................................................................................. 61 Use a CDN to cache static file assets....................................................................................................... 61 Use .NET 4.5’s async support to avoid blocking calls .............................................................................. 61 Summary ................................................................................................................................................. 64 Resources ................................................................................................................................................ 64 Single Sign-On ............................................................................................................................................. 66 Introduction to WAAD ............................................................................................................................ 66 Set up a WAAD tenant ............................................................................................................................ 69 Create an ASP.NET app that uses WAAD for single sign-on ................................................................... 82 Summary ................................................................................................................................................. 87 Resources ................................................................................................................................................ 88 Data Storage Options .................................................................................................................................. 89 Data storage options on Windows Azure ............................................................................................... 89 Hadoop and MapReduce ........................................................................................................................ 91 Platform as a Service (PaaS) versus Infrastructure as a Service (IaaS) ................................................... 95 Choosing a data storage option .............................................................................................................. 98 Demo – using SQL Database in Windows Azure ................................................................................... 100 Entity Framework versus direct database access using ADO.NET ........................................................ 108 SQL databases and the Entity Framework in the Fix It app .................................................................. 108 Choosing SQL Database (PaaS) versus SQL Server in a VM (IaaS) in Windows Azure .......................... 110 Summary ..............................................................................................................................................