Pro Microservices in .NET 10: A Holistic Approach to Building Microservices in C#. 2 Ed

Pro Microservices in .NET 10: A Holistic Approach to Building Microservices in C#. 2 Ed

Pro Microservices in .NET 10: A Holistic Approach to Building Microservices in C#. 2 Ed
Автор: Richardson Rob, Whitesell Sean
Дата выхода: 2025
Издательство: Apress Media, LLC.
Количество страниц: 261
Размер файла: 2.2 MB
Тип файла: PDF
Добавил: Aleks-5
 Проверить на вирусы

Table of Contents....5

About the Authors....13

About the Technical Reviewer....14

Acknowledgments....15

Foreword....16

Introduction....17

Chapter 1: Introducing Microservices....19

Benefits....20

Team Autonomy....21

Service Autonomy....21

Scalability....22

Fault Isolation....23

Data Autonomy....25

Challenges to Consider....25

Microservice Beginning....27

Architecture Comparison....28

Microservice Patterns....30

API Gateway/BFF....30

External Configuration Store....32

Messaging....32

Business Process Communication....33

RPC....33

Fire-and-Forget....33

Callback....34

Pub/Sub....34

Message Format....35

Transport....35

Testing....36

Test Pyramid....36

E to E....37

Service....38

Unit Tests....38

Automation....39

Deploying Microservices....39

Versioning....39

Containers....40

Pipelines....40

Cross-Cutting Concerns....41

Monitoring....41

Logging....42

Alerting....43

Testing the Architecture....44

Summary....45

Chapter 2: Other Software Patterns....47

Monolith....48

What Is It....49

Pros and Cons....49

Best Use-Case....50

Modular Monolith....50

What Is It....51

Pros and Cons....51

Best Use-Case....51

Layered Architecture....52

What Is It....52

Pros and Cons....52

Best Use-Case....53

Event-Driven Architecture....54

What Is It....54

Pros and Cons....54

Best Use-Case....55

Pipeline Architecture....55

What Is It....55

Pros and Cons....56

Best Use-Case....56

Micro-Kernel....56

What Is It....57

Pros and Cons....57

Best Use-Case....57

Service-Oriented Architecture....58

What Is It....58

Pros and Cons....58

Best Use-Case....59

Microservices....59

What Is It....60

Pros and Cons....60

Best Use-Case....60

Summary....61

Choose the Right Tool for the Job....61

Chapter 3: Searching for Microservices....62

The Business....62

Domain-Driven Design....63

Domain....64

Subdomains....64

Ubiquitous Language....65

Bounded Contexts....65

Aggregates and Aggregate Roots....66

Event Storming....68

Setup....69

Color Coding....69

The Meeting....71

Seeing the Domains....75

Domain Models....76

Focus on Behavior....77

Domain Modelling....77

Decomposition....77

Becoming a Microservice....78

Summary....79

Chapter 4: ASP.NET Is a Great Place for Microservices....80

A Brief History of .NET....80

.NET Framework....80

.NET Core....82

Modern .NET....84

Ways to Build Microservices in ASP.NET....85

ASP.NET MVC....86

ASP.NET Razor Pages....90

ASP.NET Web API....91

ASP.NET Minimal APIs....93

Azure Functions....96

KEDA Functions....99

Aspire....101

Summary....103

Chapter 5: First Microservice....104

Interprocess Communication....104

API First Design....105

Transport Mechanisms....106

REST....106

gRPC....107

File ➤ New ➤ Project....108

Contacting Google’s Routes API....112

App Settings....112

Testing What We Have....112

Swagger....114

Leveraging gRPC....115

Incorporating gRPC....116

NuGet Packages....119

Project File....119

Testing gRPC Endpoint....120

Modify the Monolith....121

Service Discovery....121

Summary....122

Chapter 6: Microservice Messaging....123

Issues with Synchronous Communication....123

Limits of RPC....124

Messaging....124

Architecture....125

Reasons to Use Messaging....125

Loosely Coupled....125

Buffering....126

Scaling....126

Independent Processing....126

Message Types....126

Query....127

Command....127

Event....127

Message Routing....128

Broker-less....128

Brokered....128

Consumption Models....129

Competing Consumers....129

Independent Consumers....130

Delivery Guarantees....131

At Most Once....131

At Least Once....132

Once and Only Once....132

Message Ordering....133

Building the Examples....134

Building the Messaging Microservices....134

Running RabbitMQ....135

First Project....135

Building the Invoice Microservice....136

Building the Payment Microservice....138

Testing the Competing Consumers....139

Building a PubSub Demo....140

Drawbacks of Messaging....141

Summary....142

Chapter 7: Decentralizing Data....144

Current State....144

The Rule....145

Database Choices....146

Availability....146

Sharing Data....148

Duplicate Data....149

Transactional Consistency....152

CAP Theorem....152

Transactions Across Microservices....153

Sagas....154

Routing Slip....155

Choreography....157

Orchestration....159

CQRS....160

Event Sourcing....162

Scenarios....166

Scenario 1....166

Scenario 2....167

Eventual Consistency....167

Data Warehouse....169

Materialized View....170

Splitting the Monolith....171

Moving Code....172

Strangler Pattern....174

Feature Flags....174

Splitting the Database....174

Summary....177

Chapter 8: Testing Microservices....179

Cost of Errors....179

What Not to Test....180

What to Test....180

Code....181

Performance....181

System Failure Handling....182

Security....183

Testing Levels....183

Unit Testing....184

Integration Testing....185

Component Testing....186

Mocking....186

Stub....187

Contract Testing....187

Consumer-Driven Contract Testing....188

Service Testing....188

End-to-End Testing....189

End-to-End Testing Microservices....189

Consumer-Driven Contract Testing Deep Dive....192

Consumer Project....193

Consumer Test Project....196

Provider Test Project....200

Summary....202

Chapter 9: Deploying Microservices....203

Containerize a .NET Microservice....203

Containerize .NET with a Dockerfile....204

Containerize .NET with the .NET SDK....208

Deploy a Containerized .NET Microservice....210

Deploy to Azure Kubernetes Service (AKS)....211

Deploy to Azure Container Apps....216

Deploy to Azure App Service....217

Other Deployment Options....219

Reverse Proxy....220

Kubernetes Ingress....221

Application Gateway....223

API Management....226

YARP....227

Reverse Proxy Roundup....231

Summary....231

Chapter 10: Healthy Microservices....233

Is It Healthy?....233

Where Do We Look?....234

OpenTelemetry....235

Aspire....238

Adding more Instrumenters to .NET Aspire....239

Custom Logs, Traces, and Metrics....240

Azure Application Insights....246

Effective Monitoring....247

Debugging with Logs....250

Summary....252

Index....253

Learn how to design, build, test, deploy, and monitor microservices using .NET 10.

Microservices is a pattern of separating software into small, reusable components to solve specific problems. Each microservice can be independently built, deployed, and scaled. This pattern provides enterprise grade durability and scale to meet complex business goals and customer needs in enterprise systems. While the return is valuable and the concept straightforward, applying it to an enterprise development effort is far more complicated. Where do you start? How do you find the seams between the components? And once you have all the services, how do you deploy and scale them to meet the durability and performance needs of the organization?

Pro Microservices in .NET 10 will introduce you to all that and more. The authors get you started with an overview of microservices and other development patterns, event storming, domain-driven design, and the options for developing in ASP.NET. You will use that foundational information to build a reference application throughout the book, exploring both synchronous messaging with HTTP, gRPC, and asynchronous messaging with a service bus. From there, you will create your first microservice using C# and .NET 10, test it using unit and integration tests, and package it into a Docker container. You’ll deploy the container to various Azure services including Kubernetes, Azure Container Apps, App Service, Azure Functions, and KEDA. You will also learn about communication styles, decentralizing data, and testing microservices. Finally, you will learn how to keep services healthy using OpenTelemetry for logging, Aspire for local development, and Azure Application Insights for production.

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
  • Learn about ASP.NET hosting options including MVC, Razor Pages, Web API, and Minimal APIs
  • Call microservices using RPC and messaging communication styles via HTTP and gRPC
  • Learn about asynchronous communication using an enterprise service bus
  • Comprehend decentralizing data and handling distributed transactions
  • Understand via detailed commands how Docker is used to containerize applications
  • Learn to deploy microservices to Kubernetes, Azure Container Apps, App Services, and Azure Functions
  • Leverage OpenTelemetry to make your microservices more robust

Who This Book Is For

This book is for professional developers and software architects looking to level up their skills. Readers should have basic familiarity with Visual Studio or VS Code and experience with .NET, ASP.NET Core, and C#.

New to This Edition

In this new and updated volume, the authors explore new features from .NET 10 and C# 14 that launched in November 2025, making it easier than ever to design, architect, build, test, and deploy microservices. These enhancements include testing patterns, Docker, Kubernetes, Azure deployment, YARP, and Aspire.


Похожее:

Список отзывов:

Нет отзывов к книге.