首页 > 解决方案 > 从 azure 函数获取标头值

问题描述

我可以使用以下方法从 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;
    }

标签: azureazure-functionsazure-eventhub

解决方案


尝试按照此处EventData所述阅读您的消息

using Microsoft.Azure.EventHubs;
...

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

推荐阅读