错误CS0234:Azure函数中缺少EventHubs程序集/元数据文件 [英] error CS0234: EventHubs assembly/metadata file missing in azure function

查看:60
本文介绍了错误CS0234:Azure函数中缺少EventHubs程序集/元数据文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了具有许多基数的EventHub触发函数.

I have created EventHub trigger function with many cardinality.

以下是run.csx中的代码

Following is code in 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}");

}

在进行编译时,我遇到了错误

While doing compilation I am getting below error

2018-11-27T09:22:49.971 [Error] run.csx(1,1): error CS0006: Metadata file 'Microsoft.Azure.EventHubs' could not be found
2018-11-27T09:22:50.034 [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:22:50.113 [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:22:50.202 [Error] run.csx(8,24): error CS0246: The type or namespace name 'EventData' could not be found (are you missing a using directive or an assembly reference?)

我的function.json看起来像

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "eventMessage",
      "direction": "in",
      "eventHubName": "myEventHub",
      "connection": "consumer_hub",
      "consumerGroup": "$Default",
      "cardinality": "many"
    }
  ]
}

您能帮忙为什么azure函数中不提供依赖项吗?甚至azure文档也对此有参考.

Could you please help why dependency is not available in azure function? Even azure documentation has reference for this.

https://docs.microsoft.com/zh-CN/azure/azure-functions/functions-bindings-event-hubs

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs

推荐答案

你好您所指的示例适用于功能1.x. 该文档未随运行时2.x​​的示例一起更新

The example that you are referring to is for Function 1.x. The documentation is not updated with the examples of runtime 2.x

请参考下面的Eventhub触发器示例,该示例适用于Function runtime v2.x

Please refer the below example of Eventhub trigger which for Function runtime v2.x

using System;

public static void Run(string myEventHubMessage, ILogger log)
{
    log.LogInformation(


"C#事件中心触发函数处理了一条消息:{myEventHubMessage}"); }
"C# Event Hub trigger function processed a message: {myEventHubMessage}"); }

如果您可以在同一

Also it would be great if you can open an github issue in the bottom of the same document so that we can track and update it.


这篇关于错误CS0234:Azure函数中缺少EventHubs程序集/元数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆