Nerd For Tech
Published in

Nerd For Tech

Generic Serverless CQRS Azure Functions Endpoints

In this post I will briefly describe how you can implement a serverless, generic CQRS Http Endpoint using Azure Functions and MediatR.

Let’s imagine we have an ICommand and an IQuery<T> interface. Here we implement them by extending existing MediatR contracts:

Then, we can implement two generic Functions which are triggered by a Http request and will send those Commands and Queries via MediatR to it’s handlers:

Then you can simply send commands and queries from a client to the server which are executed in a serverless manner:

This implementation is extremely flexible and can be easily adjusted and extended. For example you can simple generate TypeScript representations of those commands and queries (which is what I have done in some projects).

For a more complete example (yes — it’s yet another TodoList sample), take a look at this GitHub Repository: Cogax/azure-functions-todolist (



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store