1

I'm trying to filter the devices on my IoT Hub, I need to get only devices that starts with specific Mac Address.

This is the query I'm trying:

SELECT * FROM devices where starts_with(deviceId, 'D8B0')

But I'm getting

Internal Server Error

I also tried:

SELECT * FROM devices where index_of(deviceId, 'D8B0') = 0

With same results

I tried from the Query Explorer on the Azure Portal, Postman and .Net SDK

Gabrielkdc
  • 105
  • 1
  • 11

1 Answers1

2

I'm afraid you cannot achieve what you're looking for using a query. As per the documentation, "when querying twins and jobs the only supported function is: IS_DEFINED(property)"

You can however use the starts_with() operator in your routing rule, so maybe that will do the trick for you. If not, you may want to add a specific tag to your device twins to indicate their 'type' as per your rule on MAC address prefix.

kartben
  • 2,485
  • 21
  • 24
  • 1
    Oh, I missed that line.Great idea about the type, thanks a lot. – Gabrielkdc Mar 12 '20 at 20:10
  • 1
    So assuming I have 10000s of devices how am I supposed to find/filter specific devices based on some condition/pattern like device id? Seems like a big oversight. – OverflowStack Nov 16 '20 at 15:20