Azure Functions 绑定如何工作?

How do Azure Functions Bindings Work?

我对 Azure Functions 允许通过绑定进行如此多的方法签名的方式着迷。有谁知道他们在幕后如何工作或有任何描述它的资源链接?

我知道必须指定绑定,但框架如何确定要调用的方法签名?

我不认为有任何 public 文档详细描述它是如何工作的,但是,该项目是开源的,因此您可以自己查看代码: https://github.com/Azure/azure-webjobs-sdk-script/

涉及的代码相当多,但我会重点关注: https://github.com/Azure/azure-webjobs-sdk-script/tree/dev/src/WebJobs.Script/Description

获取函数参数的代码如下: https://github.com/Azure/azure-webjobs-sdk-script/blob/dev/src/WebJobs.Script/Description/DotNet/DotNetFunctionDescriptorProvider.cs#L72

了解绑定工作原理的一个好方法是自己编写一个!我们有一个 wiki 页面 Binding Extensions Overview on how to get started, along with links to sample bindings and starter projects. The general binding pipeline is described in The Binding Process. Even if you don't go off and write your own extension, those links will help you understand things. You could also debug through the sample bindings or actual bindings to see how they work - it's all open source :) Many of the bindings you'll recognize from Azure Functions live in this azure-webjobs-sdk-extensions repo, so you can see their inner workings there. Other core bindings live in azure-webjobs-sdk.

所有 Azure Functions 绑定都在幕后,如那些 wiki 链接中所述的 WebJobs SDK 绑定扩展。 Azure Functions 在此基础之上分层,并为其带来基于跨语言 JSON 的元数据模型,如 Azure Functions: The Journey 博客 post.

中所述。