2

I would like to to know if there is a way to directly connect to IOT-Centrals Rest-API, I would like to create a web-application from the telemetry data which are displayed there. As far as my knowledge gets, I believe i need to get that Json string to port the data to my web-app. I am open to any suggestion :)

Thank you very much everyone!

Cat
  • 73
  • 6

1 Answers1

2

The Azure IoT Central (IoTC) is a SaaS application built on the top of the internal Azure IoT Hub. The goal of the IoTC is to hide and abstract all infrastructure around the IoT Hub for rapid development of the IoT Solution. For this reason, the IOTC is giving to you some access permission for device connectivity, etc.

I do recommend to read the document Device connectivity for Azure IoT Central, where you can find the references how to obtain a device connection string based on the IoT Central properties such as scopeId, deviceId and primaryKey.

Once you have a device connection string, you can connect your device to the internal IoT Hub of the Azure IoT Central.

The following example shows a demonstration of the publishing telemetry data of the Plug & Play IoT device to the IoT Central preview application (Plug and Play IoT feature). Note, that the Authorization header is required for the POST request. This sas token can be obtained from the device connection string.

enter image description here

and the IoT Central shows the result on the dashboard:

enter image description here

As you can see the above POST request, the "hard part" is to obtain the namespace of the internal IoT Hub, in my example is the value iotc-1e97f318-f85b-42fa-88f8-4f27f7d5a85d. Once we have this value, the device connection string is:

HostName=iotc-1e97f318-f85b-42fa-88f8-4f27f7d5a85d.azure-devices.net;DeviceId=azurekit-1;SharedAccessKey=**device-primary-key**

p.s. if you are using a C# and need a help with an implementation of the device connection string and Authorization header for connectivity to the Azure IoT Central, I can add it to this thread. Also, have a look at how is implemented an IoTC-Device-Bridge.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • 1
    Hi Roman, the Question is not about connecting devices. We need to know, how we can retrieve data to visualize it on a custom web app. We are looking for a REST Api. – Johannes Schweer Sep 26 '19 at 05:28
  • 1
    There is no documented way to pull-up the telemetry data from the IoTC. However, the IoTC supports a **Data Export** feature where the telemetry data can be pushed to the Blob Storage, Service Bus or Event Hub. I do recommend to push them to the Event Hub. Using the *EventProcessorHost* in your web application can be easy to consume them in the realtime, https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-event-processor-host. – Roman Kiss Sep 26 '19 at 13:59
  • 1
    In the case, when your business requirements need to use only the REST Api, the telemetry data can be exported to the Service Bus queue. To pull-up the messages (one by one) from the queue can be used the REST Api, https://learn.microsoft.com/en-us/rest/api/servicebus/receive-and-delete-message-destructive-read, Note, that there is no a REST batch operation for retrieving messages from the service bus entity. – Roman Kiss Sep 26 '19 at 15:09
  • Thanks, Roman!; I have a question about how to connect to iot hub behind iotc. What I really need is to show iot hub devices/edge on Visual Studio Code. Every time, VS require registering an iot hub or connection string to iot hub, and I can't get this connection string from the iotc. – mohamed tarek Dec 01 '21 at 02:52
  • Your question is how to get the connection string for device connected to the IoT Central App, aren't? – Roman Kiss Dec 01 '21 at 12:31