Chapter 3. Building a Microservice with ASP.NET Core
Up to this point in the book we have only been scratching at the surface of the capabilities of .NET Core. In this chapter weâre going to expand on the simple âhello worldâ middleware weâve built and create our first microservice.
Weâll spend a little time defining what a microservice is (and is not), and discuss concepts like API First and Test-Driven Development. Then weâll build a sample service that manages teams and team membership.
Microservices Defined
Today, as I have been quoted to say, we canât swing a dead cat without hitting a microservice.1
The word is everywhere, and unfortunately, it is as overloaded and potentially misleading as the acronym SOA was years ago. Every time we see the word, weâre left with questions like, âWhat is a service, really?â and âJust how micro is micro?â and âWhy donât we just call them âservices'?â
These are all great questions that we should be asking. In many cases, the answer is âIt depends.â However, in my years of building modular and highly scalable applications, Iâve come up with a definition of microservice:
A microservice is a standalone unit of deployment that supports a specific business goal. It interacts with backing services, and allows interaction through semantically versioned, well-defined APIs. Its defining characteristic is a strict adherence to the Single Responsibility Principle (SRP).
This might seem like a somewhat controversial ...
Get Building Microservices with ASP.NET Core now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.