Reputation: 11
I'm bit unclarified with Azure Functions Isolated model.
Below are the points gathered from the web.
Scenario: Azure Isolated function with Service Bus queue trigger
Execution flow (My understanding):
Help me with below questions
People, if you feel any unclarities in the above, please add a comment to resolve it.
I hope this thread might help others as well.
Upvotes: 0
Views: 94
Reputation: 977
Previously your Function code and the Azure Functions runtime shared the same process. It's a web host, and it's your Functions code, all running in one process.
The runtime handled the inbound HTTP requests by directly calling your method handler.
The Azure Functions Host runtime is still responsible for handling the inbound HTTP requests. But, your Functions app is a totally separate .NET application, running as a different process. Even in a different version of the .NET runtime.
If you run it locally you'll see two processes:
Func.exe
on Windows, dotnet WebHost
on Debian Linux)Your Isolated Functions app isn't too much different from a console app. It's definitely not a web host.
This makes even more sense when you consider that the entrypoint is Program.cs
. It's clear that no other code is involved in initialising your app. That's quite different from In-process where you define a Startup class - i.e. a method called by the Azure Functions runtime code because they're part of the same process.
So if your Functions are running in something similar to a console app, how is it handling HTTP triggers if it's not a web host any more?
The answer is that your Functions app, although isolated, has a gRPC channel exposed. The Functions Host process handles the HTTP requests for you, and passes them to your Functions app through the gRPC channel.
The gRPC channel in your Functions app isn't obvious, and it's not something you explicitly open or have control over. You might stumble across it in a stack trace if you hit a breakpoint or have an unhandled exception.
The pipeline becomes:
Function
method, and you return a responseAs mentioned above, Isolated lets you add your own Middleware classes into the processing pipeline. These run in your Function code immediately before the actual Function
method is called, for every request. In-process had no convenient way to achieve this.
Even though your Functions aren't handling the HTTP call directly, helpfully your Middleware classes can still access a representation of the HTTP request that's passed in from the Host. This enables you to check HTTP headers, for example. It's particularly useful in your Middleware classes because you can perform mandatory tasks like authentication, and it's guaranteed to execute before handling the request.
This part of your question has a good answer here: https://stackoverflow.com/a/79061613/2325216
https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-differences https://github.com/Azure/azure-functions-dotnet-worker
Upvotes: 0