azure-functions - 具有 IoT 中心触发获取发送设备的 Azure 功能

标签 azure-functions azure-iot-hub

我使用 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/

相关文章:

azure - 如何将设备注册到 Azure IOT 中心的组注册?

.net - 在 Raspberry Pi 上调试 .NET 应用程序 - dotnet 已退出,代码为 0

c# - Microsoft.Azure.WebJobs.Host.Tables.TableExtension+TableToIQueryableConverter`1[TElement ]' violates the constraint of type ' TElement'

visual-studio - Azure Function 中的 ExecutionContext 不包含 'FunctionAppDirectory'

python - Azure IoT Hub设备消息结构和路由查询

azure - 使用 IoT 中心实例化 DeviceClient

powershell - 使用 Powershell 获取 Azure Function 路由参数(段)

powershell - Azure Functions 中 PowerShell 脚本的选项在哪里

Azure Blob 触发器 - 基于输入容器的动态 BlobOutput 绑定(bind)名称

azure - EventProcessorHost 方法 - 我是否需要用于事件中心的 azure blob 存储和租赁容器?