【发布时间】:2018-11-27 09:38:52
【问题描述】:
我正在尝试创建 EventHub 触发 azure 函数,该函数具有许多作为事件消息批处理的基数。
以下是run.csx中的代码
#r "Microsoft.Azure.EventHubs"
using System.Text;
using System;
using Microsoft.ServiceBus.Messaging;
using Microsoft.Azure.EventHubs;
public static void Run(EventData[] eventMessage, ILogger logger)
{
logger.LogInformation("Event: {Encoding.UTF8.GetString(eventMessage.Body)}");
logger.LogInformation("EnqueuedTimeUtc={eventMessage.SystemProperties.EnqueuedTimeUtc}");
logger.LogInformation("SequenceNumber={eventMessage.SystemProperties.SequenceNumber}");
logger.LogInformation("Offset={eventMessage.SystemProperties.Offset}");
}
沿着运行时配置 host.json 是
{
"version": "2.0"
}
和函数的配置文件function.json
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "eventMessage",
"direction": "in",
"eventHubName": "myEventHub",
"connection": "consumer_hub",
"consumerGroup": "$Default",
"cardinality": "many"
}
]
}
在编译时出现有关 assemply 的错误后丢失
2018-11-27T09:36:54.325 [Error] run.csx(1,1): error CS0006: Metadata file 'Microsoft.Azure.EventHubs' could not be found
2018-11-27T09:36:54.389 [Error] run.csx(5,17): error CS0234: The type or namespace name 'ServiceBus' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
2018-11-27T09:36:54.425 [Error] run.csx(6,23): error CS0234: The type or namespace name 'EventHubs' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?)
2018-11-27T09:36:54.522 [Error] run.csx(9,24): error CS0246: The type or namespace name 'EventData' could not be found (are you missing a using directive or an assembly reference?)
您能帮我解释一下为什么 azure 函数中没有依赖项吗?甚至 azure 文档对此都有参考。这意味着该组件应该已经存在于 azure 提供的运行时环境中。
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs
【问题讨论】:
标签: azure azure-functions