我想使用属性将输入和输出参数绑定到事件中心。
在文档中,只有使用return
语句绑定到输出的信息
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs#output---c-example
[FunctionName("EventHubOutput")]
[return: EventHub("outputEventHubMessage", Connection = "EventHubConnectionAppSetting")]
public static string Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
return $"{DateTime.Now}";
}
但我想使用ICollector<EventData> outputEventHub
作为参数来获得如下内容
[FunctionName("EventHubRewriter")]
public static void Run([EventHubTrigger("samples-workitems", Connection ="EventHubInputConnectionAppSetting")] EventData[] inputMessages, ICollector<EventData> outputMessages, TraceWriter log)
{
...
}
如何使用输出事件中心的属性生成绑定?
更新: 这是一个关于如何为属性绑定生成function.json的信息:function.json generation
答案 0 :(得分:2)
它几乎完全相同:
[EventHub("outputEventHubMessage", Connection = "EventHubConnectionAppSetting")]
ICollector<EventData> outputMessages
完整签名:
[FunctionName("EventHubRewriter")]
public static void Run(
[EventHubTrigger("samples-workitems", Connection ="EventHubInputConnectionAppSetting")]
EventData[] inputMessages,
[EventHub("outputEventHubMessage", Connection = "EventHubConnectionAppSetting")]
ICollector<EventData> outputMessages,
TraceWriter log)
{
...
}