OiiPDF.com

Microservices in .NET Core

Title Microservices in .NET Core
Author Christian Horsdal
Sub Title with examples in Nancy
ISBN 1617293377
Year 2017
Pages 344
File Formate PDF
Tags ASP.NET

Book Description

Microservices in .NET Core provides a complete guide to building microservice applications. After a crystal-clear introduction to the microservices architectural style, the book will teach you practical development skills in that style, using OWIN and Nancy.

Table Of Content

  • Microservices in .NET Core
  • brief contents
  • contents
  • preface
  • acknowledgments
  • about this book
    • Who should read this book
    • How this book is organized
    • Code conventions and downloads
    • Author Online
    • About the author
  • about the cover illustration
  • Part 1: Getting started with microservices
    • Chapter 1: Microservices at a glance
    • 1.1 What is a microservice?
    • 1.1.1 What is a microservices architecture?
    • 1.1.2 Microservice characteristics
    • 1.2 Why microservices?
    • 1.2.1 Enabling continuous delivery
    • 1.2.2 High level of maintainability
    • 1.2.3 Robust and scalable
    • 1.3 Costs and downsides of microservices
    • 1.4 Greenfield vs. brownfield
    • 1.5 Code reuse
    • 1.6 Serving a user request: an example of how microservices work in concert
    • 1.6.1 Main handling of the user request
    • 1.6.2 Side effects of the user request
    • 1.6.3 The complete picture
    • 1.7 A .NET microservices technology stack
    • 1.7.1 Nancy
    • 1.7.2 OWIN
    • 1.7.3 Setting up a development environment
    • 1.8 A simple microservices example
    • 1.8.1 Creating an empty ASP.NET Core application
    • 1.8.2 Adding Nancy to the project
    • 1.8.3 Adding a Nancy module with an implementation of the endpoint
    • 1.8.4 Adding OWIN middleware
    • 1.9 Summary
    • Chapter 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
    • 2.4 Summary
  • Part 2: Building microservices
    • Chapter 3: Identifying and scoping microservices
    • 3.1 The primary driver for scoping microservices: business capabilities
    • 3.1.1 What is a business capability?
    • 3.1.2 Identifying business capabilities
    • 3.1.3 Example: point-of-sale system
    • 3.2 The secondary driver for scoping microservices: supporting technical capabilities
    • 3.2.1 What is a technical capability?
    • 3.2.2 Examples of supporting technical capabilities
    • 3.2.3 Identifying technical capabilities
    • 3.3 What to do when the correct scope isn’t clear
    • 3.3.1 Starting a bit bigger
    • 3.3.2 Carving out new microservices from existing microservices
    • 3.3.3 Planning to carve out new microservices later
    • 3.4 Well-scoped microservices adhere to the microservice characteristics
    • 3.4.1 Primarily scoping to business capabilities leads to good microservices
    • 3.4.2 Secondarily scoping to supporting technical capabilities leads to good microservices
    • 3.5 Summary
    • Chapter 4: Microservice collaboration
    • 4.1 Types of collaboration: commands, queries, and events
    • 4.1.1 Commands and queries: synchronous collaboration
    • 4.1.2 Events: asynchronous collaboration
    • 4.1.3 Data formats
    • 4.2 Implementing collaboration
    • 4.2.1 Setting up a project for Loyalty Program
    • 4.2.2 Implementing commands and queries
    • 4.2.3 Implementing commands with HTTP POST or PUT
    • 4.2.4 Implementing queries with HTTP GET
    • 4.2.5 Data formats
    • 4.2.6 Implementing an event-based collaboration
    • 4.3 Summary
    • Chapter 5: Data ownership and data storage
    • 5.1 Each microservice has a data store
    • 5.2 Partitioning data between microservices
    • 5.2.1 Rule 1: Ownership of data follows business capabilities
    • 5.2.2 Rule 2: Replicate for speed and robustness
    • 5.2.3 Where does a microservice store its data?
    • 5.3 Implementing data storage in a microservice
    • 5.3.1 Storing data owned by a microservice
    • 5.3.2 Storing events raised by a microservice
    • 5.3.3 Setting cache headers in Nancy responses
    • 5.3.4 Reading and using cache headers
    • 5.4 Summary
    • Chapter 6: Designing for robustness
    • 6.1 Expect failures
    • 6.1.1 Keeping good logs
    • 6.1.2 Using correlation tokens
    • 6.1.3 Rolling forward vs. rolling back
    • 6.1.4 Don’t propagate failures
    • 6.2 The client side’s responsibility for robustness
    • 6.2.1 Robustness pattern: retry
    • 6.2.2 Robustness pattern: circuit breaker
    • 6.3 Implementing robustness patterns
    • 6.3.1 Implementing a fast-paced retry strategy with Polly
    • 6.3.2 Implementing a circuit breaker with Polly
    • 6.3.3 Implementing a slow-paced retry strategy
    • 6.3.4 Logging all unhandled exceptions
    • 6.4 Summary
    • Chapter 7: Writing tests for microservices
    • 7.1 What and how to test
    • 7.1.1 The test pyramid: what to test in a microservices system
    • 7.1.2 System-level tests: testing a complete microservice system end-to-end
    • 7.1.3 Service-level tests: testing a microservice from outside its process
    • 7.1.4 Unit-level tests: testing endpoints from within the process
    • 7.2 Testing libraries: Nancy.Testing and xUnit
    • 7.2.1 Meet Nancy.Testing
    • 7.2.2 Meet xUnit
    • 7.2.3 xUnit and Nancy.Testing working together
    • 7.3 Writing unit tests using Nancy.Testing
    • 7.3.1 Setting up a unit-test project
    • 7.3.2 Using the Browser object to unit-test endpoints
    • 7.3.3 Using a configurable bootstrapper to inject mocks into endpoints
    • 7.4 Writing service-level tests
    • 7.4.1 Creating a service-level test project
    • 7.4.2 Creating mocked endpoints
    • 7.4.3 Starting all the processes of the microservice under test
    • 7.4.4 Executing the test scenario against the microservice under test
    • 7.5 Summary
  • Part 3: Handling cross-cutting concerns: building a reusable microservice platform
    • Chapter 8: Introducing OWIN: writing and testing OWIN middleware
    • 8.1 Handling cross-cutting concerns
    • 8.2 The OWIN pipeline
    • 8.2.1 What belongs in OWIN, and what belongs in Nancy?
    • 8.3 Writing middleware
    • 8.3.1 Middleware as lambdas
    • 8.3.2 Middleware classes
    • 8.4 Testing middleware and pipelines
    • 8.5 Summary
    • Chapter 9: Cross-cutting concerns: monitoring and logging
    • 9.1 Monitoring needs in microservices
    • 9.2 Logging needs in microservices
    • 9.2.1 Structured logging with Serilog
    • 9.3 Implementing the monitoring middleware
    • 9.3.1 Implementing the shallow monitoring endpoint
    • 9.3.2 Implementing the deep monitoring endpoint
    • 9.3.3 Adding the monitoring middleware to the OWIN pipeline
    • 9.4 Implementing the logging middleware
    • 9.4.1 Adding correlation tokens to all log messages
    • 9.4.2 Adding a correlation token to all outgoing HTTP requests
    • 9.4.3 Logging requests and request performance
    • 9.4.4 Configuring an OWIN pipeline with a correlation token and logging middleware
    • 9.5 Summary
    • Chapter 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 Meet IdentityServer
    • 10.2.2 Implementing authentication with IdentityServer middleware
    • 10.2.3 Implementing microservice-to-microservice authorization with IdentityServer and middleware
    • 10.2.4 Implementing user authorization in Nancy modules
    • 10.3 Summary
    • Chapter 11: Building a reusable microservice platform
    • 11.1 Creating a new microservice should be quick and easy
    • 11.2 Creating a reusable microservice platform
    • 11.3 Packaging and sharing middleware with NuGet
    • 11.3.1 Creating a package with logging and monitoring middleware
    • 11.3.2 Creating a package with authorization middleware
    • 11.3.3 Creating a package with rest client factory
    • 11.3.4 Automatically registering an HTTP client factory in Nancy’s container
    • 11.3.5 Using the microservice platform
    • 11.4 Summary
  • Part 4: Building applications
    • Chapter 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 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
    • 12.4 Summary
  • Appendix A: Development environment setup
    • A.1 Setting up an IDE
    • A.1.1 Visual Studio 2015
    • A.1.2 Visual Studio Code
    • A.1.3 ATOM
    • A.1.4 JetBrains Rider
    • A.2 Setting up the dotnet command-line interface
    • A.3 Setting up Yeoman ASP.NET generator
    • A.4 Setting up Postman
    • A.5 Installing SQL Server Express
  • Appendix B: Deploying to production
    • B.1 Deploying HTTP APIs
    • B.1.1 Windows servers
    • B.1.2 Linux servers
    • B.1.3 Azure Web Apps
    • B.1.4 Azure Service Fabric
    • B.2 Deploying event consumers
    • B.2.1 Windows servers
    • B.2.2 Linux servers
    • B.2.3 Azure WebJobs
    • B.2.4 Azure Functions
    • B.2.5 Amazon Lambda
  • Further reading
    • Microservices
    • Software design and architecture in general
    • Technologies used
  • index
    • Symbols
    • Numerics
    • A
    • B
    • C
    • D
    • E
    • F
    • G
    • H
    • I
    • J
    • K
    • L
    • M
    • N
    • O
    • P
    • Q
    • R
    • S
    • T
    • U
    • V
    • W
    • X
    • Y