按消息类型将事件中心消息路由到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:
您的条件将为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消息匹配时,将该消息放入队列.此队列触发另一个仅处理匹配消息的功能