按消息类型将事件中心消息路由到Azure功能 [英] Routing Event Hub messages to Azure funtion by message type

查看:71
本文介绍了按消息类型将事件中心消息路由到Azure功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Azure函数来侦听Azure IoT中心实例.当我向IoT中心发布消息时,我会像这样设置属性:

I've create an Azure Function to listen to an Azure IoT Hub instance. When I post message to the IoT Hub I set a property like so:

        Message iotMessage = new Message([myMessage]);
        iotMessage.Properties.Add("Type", [MessageType]);

在Azure Function端,我希望Azure函数仅接收/处理具有Type属性并且Type属性等于"MessageType1"的消息.

At the Azure Function end I want the Azure function only to receive/process messages that have a Type property and where the Type property equals "MessageType1".

我看不到Azure函数中执行此操作的方法.有人可以建议这样做吗?

I cannot see a way to do this in an Azure function. Can someone advise if this is possible?

推荐答案

编辑:这似乎是您要查找的内容:

this appears to be what you're looking for:

https://docs.microsoft.com/zh-cn/azure/iot-hub/iot-hub-csharp-csharp-process -d2c#向您的iot轮毂添加队列并向其发送路由消息

您的条件将为Type = MessageType1,并且您将使函数触发器脱离输出队列.

Your condition would be Type=MessageType1 and you would have the function trigger off of the output queue.

您为Azure函数使用哪种类型的输入绑定?

What type of input binding are you using for your Azure Function?

AFAIK,目前无法一步完成.但是,您有一些选择:

AFAIK, this isn't currently possible in one step. However, there are a few options you have:

  • 将IoT中心连接到ServiceBus主题/订阅,这使您可以根据属性进行一些过滤.触发按MessageType1过滤的订阅
  • 具有专用于过滤IoT中心消息的功能.当它与MessageType1消息匹配时,将该消息放入队列.此队列触发另一个仅处理匹配消息的功能

这篇关于按消息类型将事件中心消息路由到Azure功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆