Pro Microservices in .NET 6 : With Examples Using ASP.NET Core 6, MassTransit, and Kubernetes
معرفی کتاب «Pro Microservices in .NET 6 : With Examples Using ASP.NET Core 6, MassTransit, and Kubernetes» نوشتهٔ Peter Hollins و Sean Whitesell, Rob Richardson, Matthew D. Groves، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2022. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. xv About the Technical Reviewer Mike Benkovich A developer, business owner, consultant, cloud architect, Microsoft Azure MVP, and an online instructor, Mike Benkovich is an alumni of Microsoft from 2004 to 2012 where he helped build developer communities across the United States, through work on Microsoft Across America, MSDN Events, MSDN Webcasts, DPE, and Channel 9. He's helped to create and grow developer conferences and user groups in various cities across the United States. While at Microsoft he helped create the Azure Boot Camp events that were run in cities across the United States and at PDC and TechEd before it was transferred to the community. In his spare time he helped start a Toastmaster club for Geeks called TechMasters in Minneapolis where we grow speakers for conferences. He's a LinkedIn Learning Instructor for Azure, having developed many online courses. Mike actively works in Azure Cloud Governance, Application Architecture, and Software Delivery consulting. xvii xix Software development is in the middle of a revolution. Moving away from monolithic application development with a team working on a large project that ships on a slow cadence to microservice based development where the application is broken into smaller pieces, which version independently, are built by smaller teams and ship on a fast cadence. .NET 6 is part of the revolution of .NET that makes it the perfect framework for building these microservice based applications. .NET was re-imagined starting in 2016 to be the highest performance full stack development framework running across Linux, macOS and Windows on x86, x64, Arm32, Arm64 and M1 architectures. It includes support for cross platform RPC with gRPC, support for API's with Web API and Minimal API's and support for services with Worker Template. Sean, Rob, and Matt have been building microservices in .NET and speaking on this form of development for many years. This book will help you learn how to build modern applications with microservices using the latest version of .NET. I'm excited to see what you will build! Scott Hunter VP Director, Azure Developer Experience Microsoft Foreword xxi Table of Contents About the Authors About the Technical Reviewer Acknowledgments Foreword Introduction Chapter 1: Introducing Microservices Benefits Team Autonomy Service Autonomy Scalability Fault Isolation Data Autonomy Challenges to Consider Microservice Beginning Architecture Comparison Microservice Patterns API Gateway/BFF External Configuration Store Messaging Business Process Communication RPC Fire-and-Forget Callback Pub/Sub Message Format Transport Testing Test Pyramid E to E Service Unit Tests Automation Deploying Microservices Versioning Containers Pipelines Cross-Cutting Concerns Monitoring Logging Alerting Testing the Architecture Summary Chapter 2: ASP.NET Core Overview A Brief History of .NET Long-Term Support Presentation Frameworks Installing Requirements Installing .NET 6.0 and ASP.NET Core Installing Visual Studio Installing Visual Studio Code .NET 6.0 at a Glance MVC at a Glance Routing Controller View Model ASP.NET Core Middleware ASP.NET Core Web API Razor Pages Minimal APIs Summary Chapter 3: Searching for Microservices The Business Domain-Driven Design Domain Subdomains Ubiquitous Language Bounded Contexts Aggregates and Aggregate Roots Event Storming Setup Color Coding The Meeting Seeing the Domains Domain Models Focus on Behavior Domain Modelling Decomposition Becoming a Microservice Summary Chapter 4: First Microservice Interprocess Communication API First Design Transport Mechanisms REST gRPC File – New – Project Contacting Google’s Distance API App Settings New Class Library Map Info Controller Testing What We Have Swagger Leveraging gRPC Incorporating gRPC NuGet Packages Project File Startup Modifications Testing gRPC Endpoint Modify the Monolith Service Discovery Summary Chapter 5: Microservice Messaging Issues with Synchronous Communication Limits of RPC Messaging Architecture Reasons to Use Messaging Loosely Coupled Buffering Scaling Independent Processing Message Types Query Command Event Message Routing Broker-less Brokered Consumption Models Competing Consumers Independent Consumers Delivery Guarantees At Most Once At Least Once Once and Only Once Message Ordering Building the Examples Building the Messaging Microservices Running RabbitMQ First Project Building the Invoice Microservice Building the Payment Microservice Building a Test Client Testing What We Have Play-by-Play Explanation Drawbacks of Messaging Summary Chapter 6: Decentralizing Data Current State The Rule Database Choices Availability Sharing Data Duplicate Data Transactional Consistency CAP Theorem Transactions Across Microservices Sagas Routing Slip Choreography Orchestration CQRS Event Sourcing Scenarios Scenario 1 Scenario 2 Eventual Consistency Data Warehouse Materialized View Splitting the Monolith Moving Code Strangler Pattern Feature Flags Splitting the Database Summary Chapter 7: Testing Microservices Cost of Errors What Not to Test What to Test Code Performance System Failure Handling Security Testing Levels Unit Testing Integration Testing Component Testing Mocking Stub Contract Testing Consumer-Driven Contract Testing Service Testing End-to-End Testing Consumer-Driven Contract Testing Deep Dive Consumer Project Consumer Test Project Provider Project Provider Test Project Testing Messaging-Based Microservices Testing Consumer Messaging Testing Producer Messaging Summary Chapter 8: Containerization Why Containers? It Works on My Machine! Onboarding Microservices What Is Docker? Installing Docker Docker Basics Docker run run -d --name myWebSite -p nginxdemos/hello Docker stop Docker start Docker ps Docker images Docker inspect Docker rm and rmi Microservices and Docker Adding Docker Support Create ASP.NET Image Use Docker-Compose image environment ports Push to Docker Hub Build an Image Docker push Kubernetes Kubernetes on Azure: AKS Azure Portal Azure CLI Connect to the Cluster Define Kubernetes Objects apiVersion kind metadata spec spec.replicas spec.template spec.template.metadata spec.template.containers spec.template.containers[0].image spec.template.containers[0].resources spec.template.containers[0].imagePullPolicy spec.template.containers[0].name spec.template.containers[0].ports Deploy to the Cluster Deploying Databases Pod Replacement Horizontal Scaling StatefulSets The Operator Pattern Summary Chapter 9: Healthy Microservices Is It Healthy? Where Do We Look? Logging Logging with ASP.NET Core and Serilog Avoiding “God” Classes Metrics Prometheus and Grafana Prometheus Grafana Monitoring Docker ASP.NET Prometheus Sink Custom Metrics Tracing About OpenTelemetry Add OpenTelemetry to .NET Visualize Tracing Trees in Jaeger Custom Metrics Effective Monitoring Debugging with Logs Summary Index Know the fundamentals of creating and deploying microservices using .NET 6 and gain insight from prescriptive guidance in this book on the when and why to incorporate them. The microservices architecture is a way of distributing process workloads to independent applications. This distribution allows for the independent applications to scale and evolve separately. It also enables developers to dismantle large applications into smaller, easier-to-maintain, scalable parts. While the return is valuable and the concept straightforward, applying it to an application is far more complicated. Where do you start? How do you find the optimal dividing point for your app, and strategically, how should your app be parceled out into separate services? Pro Microservices in .NET 6 will introduce you to all that and more. The authors get you started with an overview of microservices, .NET 6, event storming, and domain-driven design. You will use that foundational information to build a reference application throughout the book. From there, you will create your first microservice using .NET 6 that you can deploy into Docker and Azure Kubernetes Service. You will also learn about communication styles, decentralizing data, and testing microservices. Finally, you will learn about logging, metrics, tracing, and use that information for debugging. What You Will Learn Build a foundation of basic microservices architecture design Follow an example of using event storming and domain-driven design to understand the monolithic application modified for microservices Understand, via detailed commands, how Docker is used to containerize applications Get an overview of creating microservices from a monolithic application Call microservices using RPC and messaging communication styles with MassTransit Comprehend decentralizing data and handling distributed transactions Use Azure Kubernetes Service to host and scale your microservices Know the methods to make your microservices more robust Discover testing techniques for RPC and messaging communication styles Apply the applications you build for actual use Practice cross-cutting concerns such as logging, metrics, and tracing This book is for developers and software architects. Readers should have basic familiarity with Visual Studio and experience with .NET, ASP.NET, and C#. Sean Whitesell is a Microsoft MVP and cloud architect at TokenEx, where he designs cloud-based architectural solutions for hosting internal services for TokenEx. He serves as President of the Tulsa Developers Association. He regularly presents in the community at developer events, conferences, and local MeetUps. Rob Richardson is a software craftsman, building web properties in ASP.NET and Node, React, and Vue. He is a Microsoft MVP, published author, frequent speaker at conferences, user groups, and community events, and a diligent teacher and student of high-quality software development. You can find his recent work at robrich.org/presentations. Matthew D. Groves is a Microsoft MVP who loves to code. From C# to jQuery, or PHP, he will submit pull requests for anything. He got his start writing a QuickBASIC point-of-sale app for his parent's pizza shop back in the 1990s. Currently a Product Marketing Manager for Couchbase, he is the author of the book AOP in .NET, and the video Creating and Managing Your First Couchbase Cluster. Know the fundamentals of creating and deploying microservices using .NET 6 and gain insight from prescriptive guidance in this book on the when and why to incorporate them. The microservices architecture is a way of distributing process workloads to independent applications. This distribution allows for the independent applications to scale and evolve separately. It also enables developers to dismantle large applications into smaller, easier-to-maintain, scalable parts. While the return is valuable and the concept straightforward, applying it to an application is far more complicated. Where do you start? How do you find the optimal dividing point for your app, and strategically, how should your app be parceled out into separate services? Pro Microservices in .NET 6 will introduce you to all that and more. The authors get you started with an overview of microservices, .NET 6, event storming, and domain-driven design. You will use that foundational information to build a reference application throughout the book. From there, you will create your first microservice using .NET 6 that you can deploy into Docker and Azure Kubernetes Service. You will also learn about communication styles, decentralizing data, and testing microservices. Finally, you will learn about logging, metrics, tracing, and use that information for debugging. What You Will Learn Build a foundation of basic microservices architecture design Follow an example of using event storming and domain-driven design to understand the monolithic application modified for microservices Understand, via detailed commands, how Docker is used to containerize applications Get an overview of creating microservices from a monolithic application Call microservices using RPC and messaging communication styles with MassTransit Comprehend decentralizing data and handling distributed transactions Use Azure Kubernetes Service to host and scale your microservices Know the methods to make your microservices more robust Discover testing techniques for RPC and messaging communication styles Apply the applications you build for actual use Practice cross-cutting concerns such as logging, metrics, and tracing Who This Book Is For Developers and software architects. Readers should have basic familiarity with Visual Studio and experience with .NET, ASP.NET Core, and C#.
دانلود کتاب Pro Microservices in .NET 6 : With Examples Using ASP.NET Core 6, MassTransit, and Kubernetes