我使用 IoT 中心触发器创建了一个函数
log.Info($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.GetBytes())}");
该函数仅记录消息。但是我如何才能获取发送消息的设备呢?
问候 斯特凡
最佳答案
看看下面的例子:
using System;
public static void Run(string myIoTHubMessage, IDictionary<string, object> properties, IDictionary<string, object> systemproperties, TraceWriter log)
{
log.Info($"C# IoT Hub trigger function processed a message: \n\t{myIoTHubMessage}");
log.Info($"DeviceId = {systemproperties["iothub-connection-device-id"]}");
log.Info($"\nSystemProperties:\n\t{string.Join("\n\t", systemproperties.Select(i => $"{i.Key}={i.Value}"))}");
log.Info($"\nProperties:\n\t{string.Join("\n\t", properties.Select(i => $"{i.Key}={i.Value}"))}");
}
关于azure-functions - 具有 IoT 中心触发获取发送设备的 Azure 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57536832/