<p>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.</p><p>The microservices architecture is a way of distributing process workloads to independent applications. This distributi
Pro Microservices in .NET 6: With Examples Using ASP.NET Core 6, MassTransit, and Kubernetes
✍ Scribed by Sean Whitesell, Rob Richardson, Matthew D. Groves
- Publisher
- Apress
- Year
- 2022
- Tongue
- English
- Leaves
- 310
- Category
- Library
No coin nor oath required. For personal study only.
✦ Synopsis
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 6will 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#.
✦ Table of Contents
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
📜 SIMILAR VOLUMES
<p>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.</p><p>The microservices architecture is a way of distributing process workloads to independent applications. This distributi
Migrate your existing microservice cluster from ASP .NET to ASP .NET Core. While improved performance and cross-platform support are evident, this book helps you cut through the noise to determine how, when, and to what extent a migration is needed.<br />Microsoft's introduction of .NET Core has cre
Migrate your existing microservice cluster from ASP .NET to ASP .NET Core. While improved performance and cross-platform support are evident, this book helps you cut through the noise to determine how, when, and to what extent a migration is needed.<br />Microsoft's introduction of .NET Core has cre
Broaden your developer experience by learning how to use gRPC and ASP.NET Core together on the Microsoft’s developer framework, .NET 6 and discover a new way of developing APIs with gRPC. Beginning gRPC with ASP.NET Core 6 is your guide to quickly and efficiently getting down to the business of bui