Share via

Serverless functions and bounded context

Mohan Radhakrishnan 1 Reputation point
2021-08-13T14:27:41.96+00:00

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
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,141 Reputation points
    2021-08-17T02:45:54.293+00:00

    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

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.