# 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.

## NOTICE

You can also register the device with your Microsoft Azure IoT Hub on the Microsoft Azure IoT website.

1. Set up an Microsoft Azure IoT Hub.
2. The controller must be connected to the internet.

1. Open Node-RED.
2. Add the following nodes to the workspace and connect them to a flow:
3. inject node from the input category
4. Azure IoT Hub Registry node from the cloud category
5. debug node from the output category
6. Double-click the inject node to open the Edit node dialogue.
7. In the text box Payload, enter the desired device ID as JSON in the following format:

8. ## NOTICE

   `{"deviceId":"yourDeviceId"}`

9. Select the check box Inject once after 0.1 seconds.
10. In the list box Repeat, select none.
11. The device will be registered with the desired ID once you deploy the flow.
12. Click Done to apply your changes.
13. Double-click the Azure IoT Hub Registry node to open the Edit node dialogue.
14. In the text box connectionString, enter the IoT Hub connection string.
15. Click Done to apply your changes.
16. Click Deploy.
17. The inkjet 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.

18. ## NOTICE

    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.

19. Note down the device ID and its keys.