ebook img

Hands-On Microservices with C# 8 and .NET Core 3: Refactor you monolith architecture into microservices using Azure, 3rd Edition PDF

469 Pages·2020·13.846 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Hands-On Microservices with C# 8 and .NET Core 3: Refactor you monolith architecture into microservices using Azure, 3rd Edition

Hands-On Microservices with C# 8 and .NET Core 3 Third Edition Refactor you monolith architecture into microservices using Azure Gaurav Aroraa Ed Price BIRMINGHAM - MUMBAI Hands-On Microservices with C# 8 and .NET Core 3 Third Edition Copyright © 2020 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Richa Tripathi Acquisition Editor: Denim Pinto Content Development Editor: Tiksha Abhimanyu Lad Senior Editor: Afshaan Khan Technical Editor: Romy Dias Copy Editor: Safis Editing Project Coordinator: Francy Puthiry Proofreader: Safis Editing Indexer: Priyanka Dhadke Production Designer: Nilesh Mohite First published: June 2017 Second edition: December 2017 Third edition: March 2020 Production reference: 1260320 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78961-794-8 www.packt.com To my younger sister, Preeti, who always inspires me with her positive attitude toward life. I have learned a lot from her on how to be positive in life: how to achieve your goals in life even when there are obstacles preventing you from reaching them. – Gaurav Aroraa Packt.com Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Fully searchable for easy access to vital information Copy and paste, print, and bookmark content Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Foreword Microservices is more than just a buzzword. They represent a fresh new way of thinking about systems architecture that builds upon the designs and layering of the last two decades, combined with the real-world experiences of building large scalable systems at a size we once thought impossible. We've all learned about three-tiered architecture: we design our systems with the single responsibility principle, and we have tried different ways to scale and deploy our systems. Microservices combines the best of all these worlds. It aims to build systems that separate responsibility appropriately; that manage, version, and deploy services individually; and that elastically scale, backed by the power of the cloud. This new generation of cloud-native applications needed a new way of thinking about architecture. Gaurav and Ed have put together a journey that walks you through the process of creating effective microservices, using C# 8 and the new open source, cross- platform .NET Core. The book covers everything that you'll need, from architecture, an introduction to containers, and how services communicate, to the concepts behind a service mesh. Everything is backed by practical examples in real-world use cases, including IoT. I'm thrilled that you're coming along this journey with us, and I'm excited to see what you'll be able to build with this new knowledge. Scott Hanselman Partner Program Manager .NET Open Source Contributors About the authors Gaurav Aroraa is a serial entrepreneur and start-up mentor. He has done an M.Phil in computer science. He is a Microsoft MVP award recipient. He is a lifetime member of the Computer Society of India (CSI), is an advisory member and senior mentor at IndiaMentor, is certified as a Scrum trainer/coach, is ITIL-F certified, and is PRINCE-F and PRINCE-P certified. He is an open source developer and a contributor to the Microsoft TechNet community. Recently, Gaurav was awarded "Icon of the year – excellence in Mentoring Technology Startups" for 2018-19 by Radio City, a Jagran initiative, for his extraordinary work during his 22-year career in the industry in the field of technology mentoring. In life, it's hard to understand things when you don't find support. My family is one such support system and I am the luckiest to have them. I would like to thank my wife, Shuby Aroraa, and my little angel, Aarchi Arora, who gave me permission to write and invest time in this book. A special thanks to the Packt team (especially Tiksha, Afshaan, and Richa) and Andreas Helland. Also, a big thanks to Ed Price (my coauthor) and Scott Hanselman. Ed Price is a senior program manager in engineering at Microsoft, with an MBA in technology management. He has run Microsoft customer feedback programs for Azure Development, Service Fabric, IoT, and Visual Studio. He was also a technical writer at Microsoft for 6 years, helped to lead TechNet Wiki, and now leads efforts to publish key guidance from AzureCAT (Customer Advisory Team), especially in the development of microservices. He is the coauthor of Learn to Program with Small Basic. About the reviewer Andreas Helland has a degree in software engineering and over 20 years of experience in building products and services. He has worked both with the development side and the infrastructure side and holds a number of Microsoft certifications across various skill sets. This also led him to become an early adopter of Azure. After building up his knowledge working in the telecommunications industry, he switched to consulting, and currently works as an architect for Capgemini where he assists customers on how to utilize the cloud in the best ways possible. He specializes in Azure Active Directory and works closely with the Identity teams at Microsoft, both in testing new services and providing feedback based on learnings from the field. I have to thank my family for allowing me to spend so much time "in my lab" working on my pet projects as well as being more or less understanding of why a home needs proper IT infrastructure. I've also been lucky with having employers that have given me great freedom to work with the things I've wanted to and letting me "go crazy" with the Microsoft tech stack. My output is certainly not a result purely based on what I put in. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: An Introduction to Microservices 7 Technical requirements 8 The origin of microservices 8 Discussing microservices 10 Exploring monolithic architecture 10 Service-oriented architecture 12 Understanding services 13 Understanding microservice architecture 16 Messaging in microservices 18 Synchronous messaging 18 Asynchronous messaging 19 Message formats 19 Using microservices 20 The workings of microservice architecture 20 The advantages of microservices 21 SOA versus microservices 22 The prerequisites of microservice architecture 23 Understanding the problems with the monolithic architectural style 24 The challenges in standardizing a .NET stack 25 Fault tolerance 26 The scaling property of a system 27 Vertical scaling or scale-up 27 Horizontal scaling or scale-out 28 Deployment challenges 28 Organizational alignment 29 Modularity 30 Big database 31 Prerequisites for microservices 31 Functional overview of the application 33 Solutions for the current challenges 34 Handling deployment problems 35 Making better monolithic applications 35 Introducing dependency injections 35 Database refactoring 40 Database sharding and partitioning 41 DevOps culture 43 Automation 43 Testing 43 Versioning 44 Deployment 44 Table of Contents Identifying decomposition candidates within monolithic 45 Important microservices advantages 46 Technology independence 46 Interdependency removal 46 Alignment with business goals 47 Cost benefits 47 Easy scalability 47 Security 48 Data management 48 Integrating monolithic applications with microservices 49 An overview of Azure Service Fabric 50 Summary 52 Questions 52 Chapter 2: Refactoring the Monolith 53 Technical requirements 53 Understanding the current and new technology stack 54 Discussion – current stack (C#, EF, and SQL Server) 54 C# 8 54 Entity Framework Core 55 Visual Studio 2019 55 Microsoft SQL Server 55 New features in .NET Core 56 New features in C# 8.0 63 Enabling support for the C# 8.0 language using Visual Studio 63 Indices and ranges 65 The readonly members 69 Default interface methods 70 The size of microservices 71 What makes a good service? 72 DDD and its importance for microservices 73 Domain model design 73 Importance for microservices 74 Understanding the concept of seam 75 Module interdependency 75 Technology 76 Team structure 76 Databases 77 Master data 80 Transactions 81 Communication between microservices 82 The benefits of the API gateway for microservices 83 API gateway versus API management 84 Revisiting the FlixOne case study 84 Prerequisites 85 Transitioning to our product service 85 Migrations 87 [ ii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.