Registering a device with Microsoft Azure IoT Hub
A device must be registered with Microsoft Azure IoT Hub before this device can exchange data with Microsoft Azure IoT Hub.

You can also register the device with your Microsoft Azure IoT Hub on the Microsoft Azure IoT website.
- Prerequisite
- Set up an Microsoft Azure IoT Hub.
- The device must be connected to the internet.
- Open Node-RED.
- Add the following nodes to the workspace and connect them to a flow:
- inject node from the input category
- Azure IoT Hub Registry node from the cloud category
- debug node from the output category
- Double-click the inject node to open the Edit node dialogue.
- In the Payload text box, enter the desired device ID as JSON in the following format:
{"deviceId":"yourDeviceId"}- Enable the Inject once after 0.1 seconds check box.
- In the Repeat list box, select none.
- The device will be registered with the desired ID once you deploy the flow.
- Click Done to apply your changes.
- Double-click the Azure IoT Hub Registry node to open the Edit node dialogue.
- In the connectionString text box, enter the IoT Hub connection string.
- Click Done to apply your changes.
- Click Deploy.
- The inject node triggers the registration of the device. The device ID and its primary and secondary key are displayed in the debug tab of the sidebar.

If nothing is displayed in the debug tab, click the button on the left side of the inject node to trigger the registration of the device again.
- Note down the device ID and its keys.