3

I would like to obtain all devices into my Azure IoT Hub system (connected, not connected, it doesn't matter).

I've read the documentation about the system itself with no result but Get a list of devices from Azure IoT Hub has become obsolete.

Is there any kind of query which let retrieve all devices associated to my system?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Istorn
  • 485
  • 1
  • 5
  • 23

1 Answers1

4

You can use the REST API Service - Query Iot Hub

Payload:

{
  "query": "SELECT deviceId FROM devices"
}
Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • There's no complete example offered with .net. Where can I find one? – Istorn Jul 10 '19 at 08:18
  • Have a look at https://learn.microsoft.com/en-us/rest/api/iothub/#common-parameters-and-headers for common headers such as Content-Type and Authorization. That's all what you need it. – Roman Kiss Jul 10 '19 at 08:37
  • the root page is **IoT Hub REST** https://learn.microsoft.com/en-us/rest/api/iothub/ and this page described all common parts such as parameters, headers, etc. for handling IoT Hub by REST APIs located in the subfolder *Reference*, where is linked also the *Service - Query IoT Hub*. – Roman Kiss Jul 10 '19 at 10:44
  • Btw. example of the query all devices using the C# service SDK is described in https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language, see *C# example*. – Roman Kiss Jul 10 '19 at 10:56
  • Perfect, what I was looking for is in your second link! I didn't find it: thank you! – Istorn Jul 10 '19 at 10:58
  • In the case of using only getting the list of all IoT devices, I do recommend to use a REST API (less dependences, etc.) – Roman Kiss Jul 10 '19 at 11:04
  • It isn't the only use I'll perform, I need also to set trigger above Status update of devices.. – Istorn Jul 10 '19 at 11:05
  • The Link "Service - Query Iot Hub" is broken. Can someone update this? – Rob S. Feb 21 '23 at 22:40