如何定义EventHub输出?

时间:2017-06-09 21:47:19

标签: azure azure-functions

我有一个Azure功能(使用VS 2017 Preview中新的预编译功能支持),可以使用事件中心的输入触发器,如下所示:

[FunctionName("ProcessSensorDataFromDevices")]
public static void Run(
    [EventHubTrigger("sensordata-ingest", Connection = "SensorDataEventHubConnection")]string sensorDataEventHubMessage,
    [EventHub("rdx-ingest", Connection = "RdxDataEventHubConnection")]out string rdxEventHubMessage,
    TraceWriter log)
{
    SensorData sensorData = Newtonsoft.Json.JsonConvert.DeserializeObject<SensorData>(sensorDataEventHubMessage);

    // Push the sensor data to the RDX Event Hub
    rdxEventHubMessage = sensorDataEventHubMessage;

    log.Info($"C# Event Hub trigger function processed a message: {sensorDataEventHubMessage}");
}

我认为输出应该被定义为类似于输入,但似乎还需要一些其他技巧。

我没有编译时错误,但在尝试在调试器中运行我的函数时出现此错误:

[6/9/2017 9:44:37 PM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
[6/9/2017 9:44:37 PM] Job host started
[6/9/2017 9:44:37 PM] The following 1 functions are in error:
[6/9/2017 9:44:37 PM] ProcessSensorDataFromDevices: Value cannot be null.
[6/9/2017 9:44:37 PM] Parameter name: eventHubName.

如果我删除处理rdxEventHubMessage的两行代码,那么一切正常。

正确定义EventHub输出需要什么?

1 个答案:

答案 0 :(得分:0)

Microsoft.NET.Sdk.Functions Nuget包中有一个错误。将其更新为1.0.0-alpha6版本(2017年6月9日星期五发布)解决了这个问题。