The Microservices architecture style is shown in the figure above. Microservices Architecture is a style in which one large application is developed as a set of small independent services. Here each service implements a specific functionality and has its own data store. Each service functionality should be small enough to implement just one use case and big enough to provide some value. Each service should be deployable separately so that it can be scaled independently. As far as possible these services should be independent of each other and if there is a need for inter-service communication then some lightweight communication protocol can be used.
Identity Provider is used to provide user authentication services to an application.
_To know details about Identity Provider & also to know about how to secure your ASP.NET Core based application you can check my series on _ASP.NET Core Security
API Gateway is a single entry point for all requests that help in managing the endpoints and coordinates with different services.
Container is a standard unit of software that bundles application or feature and all of its dependencies so that application can be deployed quickly and reliably on any new system that has container host.
Container Orchestration is a piece of software that is used to manage the life-cycle of containers in a large application. This helps to scale application on basis of the load.
Microservice is the actual small independent service which is bundled in a container along with it dependencies
Data Store is used to store microservice data and the basic principle is that each service manages its own data.
MonolithicMicroservicesSingle service/application should contain all the business functionalitySingle service should contains only one business functionalityAll service are tightly coupledAll services are loosely coupledApplication is developed in one single programming languageEach service can be in different programming languageSingle database for all services.Each service has separate databaseAll services needs to be deployed together on VMEach service can be deployed on separate VMAll services run in same process so if one service goes down then whole application breaksEach service runs in different process so failure of one service does not affects other servicesDifficult to scale a particular service as new instance will have to have all servicesCan be Scaled easily as any single service can be deployed independentlySingle large team works on whole applicationSeparate small team work on each Service which are more focused.Simple to develop & test small applicationsAdd complexity to the application by the fact that its a distributed system
.NET Core provides following advantages which works for microservices
Here we will cover in detail the step by step process to create microservice with ASP.NET Core. We will be creating an order service that will provide endpoints to Add, Cancel, Get Order By Id & Get Order(s) By Customer Id in the application. This demo has been executed in Visual Studio 2019 version 16.6.2
For microservices demo we will be creating a ASP.NET Core 3.1 Web API project.
We will be creating order microservice which will contain functionality only related to orders. We will be implementing following endpoints
Below we will quickly add the entity model for Order & enable entity framework core for order microservice.
_If you need further details on how an entity framework works then check my other article on _Entity Framework Core in ASP.NET Core 3.1
Add an order entity class
public class Order
{
public string Id { get; set; }
public string ProductId { get; set; }
public double Cost { get; set; }
public DateTime Placed { get; set; }
public string CustomerId { get; set; }
public string Status { get; set; }
}
#programming #.net core #asp.net core 3.1 #asp.net core microservices #microservices