A microservice architecture – a variant of the service-oriented architecture (SOA) structural style – arranges an application as a collection of loosely-coupled services.

Wiki

The microservices keyword is very hot keyword in recent years, that is kind of a variant of the service-oriented architecture(SOA) structural style. It can find out the microservices keyword has a “micro-” word so that means this service is not very huge services or monolithic services. Sometime, the situation most doesn’t follow the atomic service principle. A little situation will follow the atomic service principle. It must accord the situation to chose option.

What kind of microservice architecture will be good for the junior programmer/the enterprise using the microservices for first time?

In my personal viewpoint, I will provide the onion architecture option for them because the onion architecture is the 2008 year’s idea, and is very simple and clear understand the architecture in the common web application. The modern web application keep uses this concept to explained other web framework that is a good start point.

What a kind of characteristic is the microservice property in going into production with a microservices-based system?

  • Monitoring and health checks of the services and infrastructure.
  • Scalable infrastructure for the services (that is, cloud and orchestrators).
  • Security design and implementation at multiple levels: authentication, authorization, secrets management, secure communication, etc.
  • Rapid application delivery, usually with different teams focusing on different microservices.
  • DevOps and CI/CD practices and infrastructure.

From .Net microservices – architecture

How to solve the data sovereignty per microservice?

In many enterprise cases, the enterprise’s solution architecture will advise the clients or the general manager that the microservices must include all of the business logic concepts, then making the Docker image in the Docker containers, which idea is the data in the traditional approach. In the real microservice implemented, everyone microservice owns its domain data and the logic under an autonomous lifecycle, with independent deployment per microservice.

We can design more microservices with the same databases, but everyone microservices must own its domain data and the logic. It can’t cross the domain data and the logic to do some things.

How to implement the elemental microservice web API without the API Gateway in .NET?

Step 1 Create the .NET 5 projects and chose the API template projects.

Fig 1 Create project for the API template project.
Fig 2 Additional information for the API project without the HTTPS
Fig 3 The API project running result.

Step 2 Create the Core layer projects and the Infra layer projects.

Fig 4 Create the Core projects and the Infra projects.
Fig 5 Additional information for the class library.

Step 3 Setting the database connection string in appsetting.json file. A part of developers will set the developed model database connection string in the appsetting.Developement.json file, but this sample doesn’t use this method.

Step 4 Creating the generic type repository with the dispose mechanism.

Read more information. Generic Type in Repository – .NET Core Part

Step 5 Adding the AOP mechanism and install the serilog Nuget package.

Read more information. Aspect-oriented programming in .NET Core

Step 6 Create the authentication service project which chose solution is the Microsoft recommended third-party option – IdentityServer4. In the common situation, the authentication service won’t design the local services in the same network, and will be designed the closed service in other network.

Fig 6 IdentityServer4 authentication scheme.

Step 7 Create the authorization mechanism in the microservices.

Fig 7 The API with IdentityServer4 authentication mechanism.

Step 8 Create the new controller file for demoing your project which is work with IdentityServer 4 mechanism.

Fig 8 The API with IdentityServer4 running result.
Fig 9 Authorization UI on the API swagger page.
Fig 10 Authorization UI result.
Fig 11 The API swagger page result with the oauth2 authorization available.

Step 9 Try demo API on the swagger page.

Fig 12 The demo API result on the swagger page.

Reference

1 Comment

Leave a Reply