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