De La Torre C. Et
Total Page:16
File Type:pdf, Size:1020Kb
y i EDITION v2.01 DOWNLOAD available at: https://aka.ms/microservicesebook PUBLISHED BY Microsoft Developer Division, .NET and Visual Studio product teams A division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2017 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. This book is provided “as-is” and expresses the author’s views and opinions. The views, opinions and information expressed in this book, including URL and other Internet website 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. Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks of the Microsoft group of companies. Mac and macOS are trademarks of Apple Inc. The Docker whale logo is a registered trademark of Docker, Inc. Used by permission. All other marks and logos are property of their respective owners. Co-Authors: Editors: Cesar de la Torre, Sr. PM, .NET product team, Microsoft Corp. Mike Pope Bill Wagner, Sr. Content Developer, C+E, Microsoft Corp. Steve Hoag Mike Rousos, Principal Software Engineer, DevDiv CAT team, Microsoft Participants and reviewers: Jeffrey Ritcher, Partner Software Eng, Azure team, Microsoft Dylan Reisenberger, Architect and Dev Lead at Polly Jimmy Bogard, Chief Architect at Headspring Steve Smith, Software Craftsman & Trainer at ASPSmith Ltd. Udi Dahan, Founder & CEO, Particular Software Ian Cooper, Coding Architect at Brighter Jimmy Nilsson, Co-founder and CEO of Factor10 Unai Zorrilla, Architect and Dev Lead at Plain Concepts Glenn Condron, Sr. Program Manager, ASP.NET team Eduard Tomas, Dev Lead at Plain Concepts Mark Fussell, Principal PM Lead, Azure Service Fabric team, Microsoft Ramon Tomas, Developer at Plain Concepts Diego Vega, PM Lead, Entity Framework team, Microsoft David Sanz, Developer at Plain Concepts Barry Dorrans, Sr. Security Program Manager Javier Valero, Chief Operating Officer at Grupo Solutio Rowan Miller, Sr. Program Manager, Microsoft Pierre Millet, Sr. Consultant, Microsoft Ankit Asthana, Principal PM Manager, .NET team, Microsoft Michael Friis, Product Manager, Docker Inc Scott Hunter, Partner Director PM, .NET team, Microsoft Charles Lowell, Software Engineer, VS CAT team, Microsoft ii Contents Introduction ................................................................................................................................................. 1 About this guide ...................................................................................................................................................................... 1 Version ......................................................................................................................................................................................... 1 What this guide does not cover ......................................................................................................................................... 2 Who should use this guide .................................................................................................................................................. 2 How to use this guide ............................................................................................................................................................ 2 Related microservice and container-based reference application: eShopOnContainers ............................ 2 Send us your feedback! ......................................................................................................................................................... 3 Introduction to Containers and Docker .................................................................................................. 4 What is Docker?........................................................................................................................................................................ 5 Comparing Docker containers with virtual machines ........................................................................................... 6 Docker terminology ................................................................................................................................................................ 7 Docker containers, images, and registries ..................................................................................................................... 9 Choosing Between .NET Core and .NET Framework for Docker Containers ................................... 10 General guidance .................................................................................................................................................................. 10 When to choose .NET Core for Docker containers .................................................................................................. 11 Developing and deploying cross platform ............................................................................................................ 11 Using containers for new (“green-field”) projects ............................................................................................... 12 Creating and deploying microservices on containers ....................................................................................... 12 Deploying high density in scalable systems .......................................................................................................... 12 When to choose .NET Framework for Docker containers ..................................................................................... 13 Migrating existing applications directly to a Windows Server container .................................................. 13 Using third-party .NET libraries or NuGet packages not available for .NET Core .................................. 13 Using.NET technologies not available for .NET Core ......................................................................................... 13 Using a platform or API that does not support .NET Core .............................................................................. 14 Decision table: .NET frameworks to use for Docker ................................................................................................ 15 What OS to target with .NET containers...................................................................................................................... 16 Official .NET Docker images ............................................................................................................................................. 17 .NET Core and Docker image optimizations for development versus production ................................ 17 Architecting Container- and Microservice-Based Applications ........................................................ 19 Vision ......................................................................................................................................................................................... 19 Container design principles .............................................................................................................................................. 19 Containerizing monolithic applications ....................................................................................................................... 20 iii Deploying a monolithic application as a container ............................................................................................ 22 Publishing a single-container-based application to Azure App Service .................................................... 22 State and data in Docker applications ......................................................................................................................... 23 Service-oriented architecture ........................................................................................................................................... 25 Microservices architecture ................................................................................................................................................ 26 Data sovereignty per microservice ............................................................................................................................ 28 The relationship between microservices and the Bounded Context pattern ........................................... 29 Logical architecture versus physical architecture ................................................................................................ 30 Challenges and solutions for distributed data management ......................................................................... 31 Identify domain-model boundaries for each microservice ............................................................................. 36 Direct client-to-microservice communication versus the API Gateway pattern ..................................... 39 Communication in a microservice architecture .................................................................................................... 44 Creating, evolving, and versioning microservice APIs and contracts .......................................................... 54 Microservices addressability and the service registry ......................................................................................