Jasmine
Jasmine

Reputation: 155

IoTHub Event Subscription Message Routing and Filtering

Is it possible to route the IoTHub message to the Event Subscription using mesage routing / is it possible to add the filter based on IoThub device twin content for IotHub device telemetry in IoThub Event Subscription?

I have 2 event subscriptions (EventSubscriptionA and EventSubscriptionB)created in IotHub->Events (separated by filter)(Captures the Device Telemetry events). Now, I'd like to route the message based on the content in the IoTHub device twin for each telemetry sent to the IotHub from the device. i.e. if the IotHub device twin of the device contains 'a' then when the device sends the telemetry, this telemetry is routed to eventsubscriptionA(which has a built-in webhook).

Upvotes: 0

Views: 430

Answers (1)

Matthijs van der Veer
Matthijs van der Veer

Reputation: 4085

Yes, this is completely possible. You can use Message Enrichment to reach this goal. Through message enrichment, you can include part of the Device Twin in the message: Message Enrichtment

Afterwards, you can edit the filter of your Event Subscription to filter on that field. Here is your example, where you want to filter on 'a'. Event Subscription filter

Now this Event Subscription will only fire messages when the Device Twin has a desired property called twinProperty with a value of a. You can also use message enrichment on the Device Twin tags, if that's more suitable.

Upvotes: 1

Related Questions