Azure WebJobs SDK 如何允许将特定参数列表注入到函数方法中?

How does the Azure WebJobs SDK allow a specific list of parameters to be injected into a Function method?

Azure SDK(用于队列)mentions a specific list of parameters that are allowed to be passed into a webjob Function

例如

You can get the following message properties by adding parameters to the method signature:

DateTimeOffset expirationTime
DateTimeOffset insertionTime
DateTimeOffset nextVisibleTime
string queueTrigger (contains message text)
string id
string popReceipt
int dequeueCount

If you want to work directly with the Azure storage API, you can also add a CloudStorageAccount parameter.

我试图在他们的源代码中找到这是如何完成的,因为我想尝试传递我自己的参数。

谁能解释一下/link这是怎么可能的/怎么做的?

首先,WebJobs SDK Quick Reference列出了队列消息属性的绑定参数,您可以查看。

其次,如果您想传递自己的参数,可以尝试create new custom binding or make existing bindings customizable

此类参数是特定触发器绑定的静态绑定合同的一部分。每个触发器绑定定义其(可能为空)一组 "built in" 绑定值。例如。 here 是 QueueTrigger 的源代码,它定义了这些值。只有这个静态契约中的值才能以这种方式绑定为方法参数。

运行时在索引时间根据触发器的契约验证方法签名,这就是我将其称为静态契约的原因。如果方法的一个或多个参数无法根据合同解析,则会发生索引错误。在运行时触发方法时,绑定合同会填充实际触发值(例如队列消息)中的值。

扩展触发器绑定可以用同样的方式定义契约。例如,hereAzure Functions 中的 HttpTrigger 绑定将路由模板中的路由参数添加到其绑定协定的位置。例如。对于像 products/{category:alpha}/{id:int?} 这样的路由模板,"category" 和 "id" 都被添加到合约中,因此可以直接作为方法参数绑定。在运行时,绑定数据会填充来自触发 http 请求的实际运行时值 URL.

本合同的定义由触发器绑定作者负责,不可从外部扩展。