Microservices in . NET

Microservices in .NET, Second Edition teaches you to build and deploy microservices using ASP.NET and Azure services. It lays out microservice architecture simply, and then guides you through several real-world projects, such as building an ecommerce shopping cart. In this fully revised edition, you...

Descripción completa

Detalles Bibliográficos
Otros Autores: Gammelgaard, Christian Horsdal, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Shelter Island, New York : Manning Publications [2021]
Edición:Second edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009635718906719
Tabla de Contenidos:
  • Intro
  • Microservices in .NET
  • Copyright
  • Praise for the first edition
  • contents
  • front matter
  • preface
  • acknowledgments
  • about this book
  • Who should read this book
  • About the code
  • liveBook discussion forum
  • about the author
  • about the cover illustration
  • Part 1 Getting started with microservices
  • 1 Microservices at a glance
  • 1.1 What is a microservice?
  • 1.2 What is a microservices architecture?
  • 1.2.1 Microservice characteristics
  • 1.3 Why microservices?
  • 1.3.1 Enabling continuous delivery
  • 1.3.2 High level of maintainability
  • 1.3.3 Robust and scalable
  • 1.4 Costs and downsides of microservices
  • 1.5 Greenfield vs. brownfield
  • 1.6 Code reuse
  • 1.7 Serving a user request: An example of how microservices work in concert
  • 1.7.1 Main handling of the user request
  • 1.7.2 Side effects of the user request
  • 1.7.3 The complete picture
  • 1.8 A .NET microservices technology stack
  • 1.8.1 ASP.NET and MVC
  • 1.8.2 Kubernetes
  • 1.8.3 Setting up a development environment
  • 1.9 A simple microservices example
  • 1.9.1 Creating an empty ASP.NET application
  • 1.9.2 Adding ASP.NET MVC to the project
  • 1.9.3 Adding an MVC controller with an implementation of the endpoint
  • Summary
  • 2 A basic shopping cart microservice
  • 2.1 Overview of the Shopping Cart microservice
  • 2.1.1 Components of the Shopping Cart microservice
  • 2.2 Implementing the Shopping Cart microservice
  • 2.2.1 Creating an empty project
  • 2.2.2 The Shopping Cart microservice's API for other services
  • 2.2.3 Fetching product information
  • 2.2.4 Parsing the product response
  • 2.2.5 Adding a failure-handling policy
  • 2.2.6 Implementing a basic event feed
  • 2.3 Running the code
  • Summary
  • 3 Deploying a microservice to Kubernetes
  • 3.1 Choosing a production environment
  • 3.2 Putting the Shopping Cart microservice in a container.
  • 3.2.1 Adding a Dockerfile to the Shopping Cart microservice
  • 3.2.2 Building and running the shopping cart container
  • 3.3 Running the shopping cart container in Kubernetes
  • 3.3.1 Setting up Kubernetes localhost
  • 3.4 Creating Kubernetes deployment for the shopping cart
  • 3.5 Running the shopping cart container on Azure Kubernetes Service
  • 3.5.1 Setting up AKS
  • 3.5.2 Running the shopping cart in AKS
  • Summary
  • Part 2 Building microservices
  • 4 Identifying and scoping microservices
  • 4.1 The primary driver for scoping microservices: Business capabilities
  • 4.1.1 What is a business capability?
  • 4.1.2 Identifying business capabilities
  • 4.1.3 Example: Point-of-sale system
  • 4.2 The secondary driver for scoping microservices: Supporting technical capabilities
  • 4.2.1 What is a technical capability?
  • 4.2.2 Examples of supporting technical capabilities
  • 4.2.3 Identifying technical capabilities
  • 4.3 The tertiary driver for scoping microservices: Supporting efficiency of work
  • 4.4 What to do when the correct scope isn't clear
  • 4.4.1 Starting a bit bigger
  • 4.4.2 Carving out new microservices from existing microservices
  • 4.4.3 Planning to carve out new microservices later
  • 4.5 Well-scoped microservices adhere to the microservice characteristics
  • 4.5.1 Primary scoping to business capabilities leads to good microservices
  • 4.5.2 Secondary scoping to support technical capabilities leads to good microservices
  • 4.5.3 Tertiary scoping to support efficiency of work
  • Summary
  • 5 Microservice collaboration
  • 5.1 Types of collaboration: Commands, queries, and events
  • 5.1.1 Commands and queries: Synchronous collaboration
  • 5.1.2 Events: Asynchronous collaboration
  • 5.1.3 Data formats
  • 5.2 Implementing collaboration
  • 5.2.1 Setting up a project for the loyalty program
  • 5.2.2 Implementing commands and queries.
  • 5.2.3 Implementing commands with HTTP POST or PUT
  • 5.2.4 Implementing queries with HTTP GET
  • 5.2.5 Implementing an event-based collaboration
  • 5.2.6 Deploying to Kubernetes
  • 5.2.7 Building a Docker container special offers microservice
  • 5.2.8 Building a Docker container for both parts of the loyalty program
  • 5.2.9 Deploying the loyalty program API and the special offers
  • 5.2.10 Deploy EventConsumer
  • Summary
  • 6 Data ownership and data storage
  • 6.1 Each microservice has a data store
  • 6.2 Partitioning data between microservices
  • 6.2.1 Rule 1: Ownership of data follows business capabilities
  • 6.2.2 Rule 2: Replicate for speed and robustness
  • 6.2.3 Where does a microservice store its data?
  • 6.3 Implementing data storage in a microservice
  • 6.3.1 Preparing a development setup
  • 6.3.2 Storing data owned by a microservice
  • 6.3.3 Storing events raised by a microservice
  • 6.3.4 Setting cache headers in HTTP responses
  • 6.3.5 Reading and using cache headers
  • Summary
  • 7 Designing for robustness
  • 7.1 Expect failures
  • 7.1.1 Keeping good logs
  • 7.1.2 Using trace IDs
  • 7.1.3 Rolling forward vs. rolling backward
  • 7.1.4 Don't propagate failures
  • 7.2 The client side's responsibility for robustness
  • 7.2.1 Robustness pattern: Retry
  • 7.2.2 Robustness pattern: Circuit breaker
  • 7.3 Implementing robustness patterns
  • 7.3.1 Implementing a fast-paced retry strategy with Polly
  • 7.3.2 Implementing a circuit breaker with Polly
  • 7.3.3 Implementing a slow-paced retry strategy
  • 7.3.4 Logging all unhandled exceptions
  • 7.3.5 Deploying to Kubernetes
  • Summary
  • 8 Writing tests for microservices
  • 8.1 What and how to test
  • 8.1.1 The test pyramid: What to test in a microservices system
  • 8.1.2 System-level tests: Testing a complete microservice system end to end.
  • 8.1.3 Service-level tests: Testing a microservice from outside its process
  • 8.1.4 Unit-level tests: Testing endpoints from within the process
  • 8.2 Testing libraries: Microsoft.AspNetCore.TestHost and xUnit
  • 8.2.1 Meet Microsoft.AspNetCore.TestHost
  • 8.2.2 Meet xUnit
  • 8.2.3 xUnit and Microsoft.AspNetCore.TestHost working together
  • 8.3 Writing unit tests using Microsoft.AspNetCore.TestHost
  • 8.3.1 Setting up a unit-test project
  • 8.3.2 Using the TestServer and HttpClient to unit-test endpoints
  • 8.3.3 Injecting mocks into endpoints
  • 8.4 Writing service-level tests
  • 8.4.1 Creating a service-level test project
  • 8.4.2 Creating mocked endpoints
  • 8.4.3 Executing the test scenario against the microservice under test
  • Summary
  • Part 3 Handling cross-cutting concerns: Building a reusable microservice platform
  • 9 Cross-cutting concerns: Monitoring and logging
  • 9.1 Monitoring needs in microservices
  • 9.2 Logging needs in microservices
  • 9.2.1 Tracing requests across microservices
  • 9.2.2 Structured logging with Serilog
  • 9.3 Implementing the monitoring endpoints
  • 9.3.1 Implementing the /health/live monitoring endpoint
  • 9.3.2 Implementing the /health/startup monitoring endpoint
  • 9.4 Implementing structured logging
  • 9.4.1 Adding a trace ID to all log messages
  • 9.4.2 Trace ID is included in outgoing HTTP requests
  • 9.4.3 Logging unhandled exceptions
  • 9.5 Implementing monitoring and logging in Kubernetes
  • 9.5.1 Configure monitoring in Kubernetes
  • Summary
  • 10 Securing microservice-to-microservice communication
  • 10.1 Microservice security concerns
  • 10.1.1 Authenticating users at the edge
  • 10.1.2 Authorizing users in microservices
  • 10.1.3 How much should microservices trust each other?
  • 10.2 Implementing secure microservice-to-microservice communication.
  • 10.2.1 Accessing the user identity in the loyalty program
  • 10.2.2 Limiting which microservices can communicate
  • Summary
  • 11 Building a reusable microservice platform
  • 11.1 Creating a new microservice should be quick and easy
  • 11.2 Handling cross-cutting concerns
  • 11.3 Creating a reusable microservice platform
  • 11.4 Packaging and sharing cross-cutting code with NuGet
  • 11.4.1 Creating a logging package
  • 11.4.2 Creating a package with monitoring endpoints
  • 11.5 The ASP.NET pipeline
  • 11.5.1 What belongs in middleware?
  • 11.6 Writing middleware
  • 11.6.1 Middleware as lambdas
  • 11.6.2 Middleware classes
  • 11.7 Testing middleware and pipelines
  • Summary
  • Part 4 Building applications
  • 12 Creating applications over microservices
  • 12.1 End user applications for microservice systems: One or many applications?
  • 12.1.1 General-purpose applications
  • 12.1.2 Specialized applications
  • 12.2 Patterns for building applications over microservices
  • 12.2.1 Composite applications: Integrating at the frontend
  • 12.2.2 API Gateway
  • 12.2.3 Backend for frontend (BFF) pattern
  • 12.2.4 When to use each pattern
  • 12.2.5 Client-side or server-side rendering?
  • 12.3 Example: A shopping cart and a product list
  • 12.3.1 Creating an API Gateway
  • 12.3.2 Creating the product list GUI
  • 12.3.3 Creating the shopping cart GUI
  • 12.3.4 Letting users add products to the shopping cart
  • 12.3.5 Letting users remove products from the shopping cart
  • Summary
  • appendix A. Development environment setup
  • A.1 Setting up an IDE
  • A.1.1 Visual Studio
  • A.1.2 Visual Studio Code
  • A.1.3 JetBrains Rider
  • A.2 Setting up the dotnet command-line interface
  • A.3 Setting up REST client in VS Code
  • A.4 Docker and Kubernetes
  • A.5 Azure CLI
  • further reading
  • index
  • inside back cover.