admin管理员组文章数量:1302329
I'm bit unclarified with Azure Functions Isolated model.
Below are the points gathered from the web.
- Azure Function code runs in the different process (worker process) and Function host runs in the different process.
- Both processes are communicated over Inter-Process Communication (context switching)
Scenario: Azure Isolated function with Service Bus queue trigger
Execution flow (My understanding):
- Function Host process starts (Host.json configurations are applied). Sets service bus queue listener
- Creates worker process as defined in the Program.cs
- When a message received in service bus queue, host process fetches it and sending to worker process through IPC (context switching).
- Worker process process the message as per the code written by user.
- After the message processed, Host process again invoked and service bus message completed.
Help me with below questions
- What are the roles of Function host process and Worker process. How both contributes in the function execution pipeline. (I'm trying to understand the clear view on execution pipeline)
- Configuration in Host.json is applied for Function Host and appsettings.json for worker process?
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.
I'm bit unclarified with Azure Functions Isolated model.
Below are the points gathered from the web.
- Azure Function code runs in the different process (worker process) and Function host runs in the different process.
- Both processes are communicated over Inter-Process Communication (context switching)
Scenario: Azure Isolated function with Service Bus queue trigger
Execution flow (My understanding):
- Function Host process starts (Host.json configurations are applied). Sets service bus queue listener
- Creates worker process as defined in the Program.cs
- When a message received in service bus queue, host process fetches it and sending to worker process through IPC (context switching).
- Worker process process the message as per the code written by user.
- After the message processed, Host process again invoked and service bus message completed.
Help me with below questions
- What are the roles of Function host process and Worker process. How both contributes in the function execution pipeline. (I'm trying to understand the clear view on execution pipeline)
- Configuration in Host.json is applied for Function Host and appsettings.json for worker process?
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.
Share Improve this question edited Feb 12 at 5:48 Div asked Feb 11 at 7:28 DivDiv 115 bronze badges 2- I think this is probably too broad for anyone to give you an answer. Can you narrow it down to a specific question? At the moment it doesn't fit StackOverflow guidelines. See meta.stackoverflow/questions/417476/… and stackoverflow/help/how-to-ask – Andrew B Commented Feb 11 at 23:35
- @AndrewB Thanks. Removed few questions and posted in another thread. This thread is only to understand the Azure function isolated model invocation and execution pipeline. – Div Commented Feb 12 at 5:51
1 Answer
Reset to default 1History: Principles of In-process Functions
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.
Background: Principles of Isolated Functions
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:
- The Functions Host process (
Func.exe
on Windows, dotnetWebHost
on Debian Linux) - A separate .NET process launched with your Functions app
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.
Actual answer: How the pipeline works
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:
- Host process receives HTTP request
- Host process calls your Functions app via gRPC
- Functions app calls your Middleware classes, if you registered any
- Functions app calls your
Function
method, and you return a response - Functions app returns the response back to the Host process via gRPC
- Host process returns the HTTP response back to the caller
Other notable differences in the pipeline
As 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.
host.json
This part of your question has a good answer here: https://stackoverflow/a/79061613/2325216
References
https://learn.microsoft/en-us/azure/azure-functions/dotnet-isolated-in-process-differences https://github/Azure/azure-functions-dotnet-worker
本文标签: netAzure Isolated FunctionHost and worker process initialization and execution flowStack Overflow
版权声明:本文标题:.net - Azure Isolated Function | Host and worker process initialization and execution flow - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741672812a2391703.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论