Search code examples
azureiotazure-iot-hub

Azure IoT Hub Message Routing on boolean application property


I'm trying to achieve a very simple routing logic in Azure IoT Hub. Whenever a telemetry message should trigger an alert the application property "hasEvents" is set to true and should be routed to a different endpoint.

I'm trying to test this in the Azure Portal but I can't seem to find the correct query syntax. enter image description here

When I hit the "Test route" button, this is what I'm getting:

  • For both hasEvents and "hasEvents" I receive this warning in the browser: The server didn't understand your query. Check your query syntax and try again.

  • hasEvents = true results in Invalid operands to binary operator '=': have 'string' and 'bool', expected 'string' and 'string'

  • "hasEvents" = "true" results in `The message didn't match the query.

Could this be an issue with the Portal or am I missing here something?


Solution

  • To route message to different endpoint, when application property "hasEvents" is set to true, you should write a query this way:

    hasEvents = 'true'
    

    Here is link that describes query syntax.

    https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-routing-query-syntax

    enter image description here