I have a dilemma on my service bus, whether to use an API (blue in the image) or Direct access to the database? (green in the image)

enter image description here

Option A Use two api endpoints. First to get accounts to process. Second is to process the accounts.

  • PRO – Single point of access to the database.
  • PRO – Business rules are centralized
  • CON – Network hops (auth and api call). Although they are hosted in the same azure resource group.
  • CON – Scaling multiple services

Option B – No Api. Azure Function and Message Handlers to directly access the database.

  • PRO – Less network hop
  • PRO – Only need to scale 1 service, which is the handler.
  • CON – Duplication of database mapping code, and possible duplication of business rules (1 in handler and 1 in api). You can argue to put business rules in a nuget package, but this is another beast with its own set of problems
  • CON – More than one has access to the database


  1. We already have an existing API – It contains the business rules. Its scaled on Azure App Service.
  2. Planning to add many different handlers that does things differently.
  3. Business rules changes frequently. 1-3 times a year in the last 7 years.
  4. Hosted in a single azure resource group and same region.
  5. This is part of a bigger microservice architecture.


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *