Web API As Azure Function - Introduction

In this blog, I have created many article around Azure Functions. This is quite promising technology and specially when working with .net ecosystem.

In recent past, we have seen that there is a movement towards isolated worker process for Azure Function and .net. Before .net 5, Azure Functions is in-process mode so here Azure Function runtime host version is used to run Azure Function created in .net. This is good but there is one problem. As new version of .net is being released, It is not easy to match same version in Azure Function. To overcome this issue from .NET 5 onwards there are In-Process and Out-of-process model (Isolated).

image.png ttps://techcommunity.microsoft.com/t5/apps-.. Original Link

Since dotnet isolated mode is available, I have explored that part. This is still in progress and from beginning Azure Function has limited functionality compare to asp.net web api and also if you are Azure Function purely as API EndPoint then it become challenging as for same requirement Web API has implementation but It is not there in Azure Functions.

In this article, I will try to explore option in which we can host Web API as Azure Functions. I am planning to make at least 2-3 articles on this topic.

In-Process Model

This is how In-process Azure Function looks like. In this Azure Function Host and function tied in single process. So here there is dependency on framework used by Azure Function Host.

image.png

Out-Of-Process Model

image.png

In this model, external out of process model is follow specific structure and guideline. Means in order to this work it needs to follow same structure which is similar to In-process but different attribute and implementation.

Custom Handler Model

image.png

Custom handler looks some what similar to Out-of-process or dotnet isolated mode. Just to make sure that dotnet isolated only supported for dotnet implementation while for custom handler , It is possible to use any language that expose specific endpoint.

If we look step wise then it is like following.

  1. External request ( for http) or any other component like service bus or such, It is being received by Azure Function Host.
  2. Request then forwarded to custom handler endpoint as per function configuration. (In this set of article we will look into that.)
  3. Custom handler process the request and it respond to function host.
  4. If there is output binding then response written to output.

For this series of article, I will take asp.net core web api as custom handler and will display implementation about how to expose that as a Azure Function.

What Next

This post is more about different hosting mode and bit of theoretical. In this series next I will cover HttpTrigger, ServiceBusTrigger and DevOps for Azure function with custom handler.