从Azure函数获取标头值

时间:2019-02-28 13:52:33

标签: azure azure-functions azure-eventhub

我可以使用以下方法从Azure函数JS中获取标头值:

module.exports = async function (context, eventHubMessages) {
    context.log(`JavaScript eventhub trigger function called for message array ${eventHubMessages}`);
    const product = context.bindingData.propertiesArray[0].productFilter;
}

如何在C#的Azure函数中获取productFilter的值。

 public static void Run([EventHubTrigger("{EventHubName}", Connection = "EventHubConnectionAppSetting")] string myEventHubMessage, Binder binder, ILogger log)
            {
                var parsedMessage = JToken.Parse(Convert.ToString(myEventHubMessage));
 DeviceInfo msg = parsedMessage.ToObject<DeviceInfo>();
var deviceId = msg.deviceId;
    }

1 个答案:

答案 0 :(得分:0)

尝试像here那样以EventData的形式阅读邮件

using Microsoft.Azure.EventHubs;
...

    public static void Run([EventHubTrigger("{EventHubName}", Connection = "EventHubConnectionAppSetting")] EventData myEventHubMessage, Binder binder, ILogger log)