question

MohanRadhakrishnan-5078 avatar image
0 Votes"
MohanRadhakrishnan-5078 asked SamaraSoucy-MSFT edited

Serverless functions and bounded context

Hi,
I thought this is a hot topic as functions or lambdas generally have a single responsibility. In the case of Spring Boot microservices connected by message brokers the event-driven model is established. The bounded contexts are clear.

But serverless function are different. They are light. Generally an event is published from a bounded context and received by other services. How does this work with azure functions ? It seems that multiple functions are needed to work on one bounded context.

Can we still publish events to another group of functions working on other bounded contexts ? Otherwise functions have no boundary and they write and read all tables without control.

What is the advice of this community ? I am interested in using Commands and events. So the REST contract stop at the API gateway and gets transformed into an event(OpenAPI/AsyncAPI). This event can be again transformed to another external service's REST contract by a function with that responsibility. But internally they are events and not REST.

Thanks

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SamaraSoucy-MSFT avatar image
0 Votes"
SamaraSoucy-MSFT answered SamaraSoucy-MSFT edited

One way to approach this would be to use one Function app for each context. Inside the app would be all the functions related to that context. The downside of that is that if you have quite a few different contexts and only a few functions in each then managing it can be unnecessarily unwieldy. In that case I might include two or more contexts in a given app with the intention of splitting them out later if needed.

Using message brokers like Service Bus or Storage queues is a common pattern for passing events between functions, as is functions calling each other directly via HTTP. Which of those you use depends on your specific use case. If you use API Management as your gateway, then it is already setup to handle routing events to multiple function apps while presenting a unified API externally.

For another viewpoint, you may want to take a look at this Build 2020 talk on Event-Driven patterns in Functions: https://channel9.msdn.com/Events/Build/2020/BOD124

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.