Azure 函数绑定:获取 EventData 和强类型消息
Azure Function binding: get both EventData and strongly typed message
我有以下函数定义。
消息类型:
type MailboxItem = {
CustomerID: int
AssetID: int
}
代码:
let Run(item: MailboxItem, userNames: string, log: TraceWriter) =
log.Verbose("F# function executing for " + item.AssetID.ToString())
和function.json
:
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "item",
"direction": "in",
"path": "eventhubpath",
"connection": <connection>,
"consumerGroup": "$Default"
},
{
"type": "blob",
"name": "userNames",
"path": "blobpath/{CustomerID}-{AssetID}",
"connection": <connection>,
"direction": "in"
}
],
"disabled": false
}
如您所见,我正在使用传入消息的属性来绑定来自 Blob 存储的输入 Blob。
现在,我需要扩展我的功能以通过 EventData
class 访问传入消息的一些元数据(例如序列号)。是否可以添加 EventData
参数,同时保留对消息正文属性的绑定?
目前没有,不幸的是,尽管这是一个常见的问题,我们正在我们的 repo here 中跟踪,希望很快就会解决。在我们这样做之前,它是一个 either/or - 您可以绑定到 EventData 或您的自定义 POCO。
我有以下函数定义。
消息类型:
type MailboxItem = {
CustomerID: int
AssetID: int
}
代码:
let Run(item: MailboxItem, userNames: string, log: TraceWriter) =
log.Verbose("F# function executing for " + item.AssetID.ToString())
和function.json
:
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "item",
"direction": "in",
"path": "eventhubpath",
"connection": <connection>,
"consumerGroup": "$Default"
},
{
"type": "blob",
"name": "userNames",
"path": "blobpath/{CustomerID}-{AssetID}",
"connection": <connection>,
"direction": "in"
}
],
"disabled": false
}
如您所见,我正在使用传入消息的属性来绑定来自 Blob 存储的输入 Blob。
现在,我需要扩展我的功能以通过 EventData
class 访问传入消息的一些元数据(例如序列号)。是否可以添加 EventData
参数,同时保留对消息正文属性的绑定?
目前没有,不幸的是,尽管这是一个常见的问题,我们正在我们的 repo here 中跟踪,希望很快就会解决。在我们这样做之前,它是一个 either/or - 您可以绑定到 EventData 或您的自定义 POCO。