Filter results by

Azure IoT – Device Registration

Linking an ARTIK gateway as an IoT device to Azure IoT Hub takes place as an auto-registration function the first time the device is connected to the Azure server, through Device Provisioning Service (DPS).

Refer to the IoT Hub Device Provisioning Service concepts article for details.

The connection process can be demonstrated through a C application supplied in the Azure IoT C SDK, as we will describe here. You would use a similar method to develop your own application for use on the ARTIK board.

C SDK Provisioning Application

To register a device that is authenticated using X.509 CA certificate security concepts, we make use of Azure’s sample client connect application that is shipped with the Azure IoT C SDK.


  1. Follow the introductory article for links and ARTIK-specific information to set up these Azure technologies:

    • IoT Hub
    • Device Provisioning Service
  2. Install dependencies and build the Azure IoT C SDK as described in the Enrollment article; you will be using the same SDK here.

Installing Keys/Certificates

Generate certificates and enroll them as described in the Enrollment article. You need not use the ARTIK board for certificate generation if you have another Linux platform where you have installed the SDK.

For each ARTIK board that you plan to try connecting as an IoT device, provision it with certificates. For example, for a Group enrollment, you would need root.pem and leaf.pem along with the key for the leaf certificate.

  • Copy the certificates to your ARTIK /etc/ssl/certs/ directory or another directory of your choice, making sure your search path will find them.

  • Copy the leaf certificate key to Secure Storage and delete any copies on unprotected storage. Follow the example in the Secure Storage article.

Registering Devices

Using only the certificates you previously created and enrolled with Azure IoT Hub and copied to your ARTIK board, along with the "ID Scope" value from your Device Provisioning Service dashboard, connect a new ARTIK device to Azure IoT Hub.

Start from this subdirectory:


  1. Update these items in prov_dev_client_sample.c
    • hsm_type = SECURE_DEVICE_TYPE_X509; -- if not already enabled
    • id_scope -- to what you see in your Device Provisioning Service dashboard.
    static const char* global_prov_uri = "
    static const char* id_scope = "0ne0002B21C";
  2. Compile the provisioning application.


  3. Run the application.


    Provisioning API Version: 1.2.8
    Registering... Press enter key to interrupt.
    . . .
    Provisioning Status: PROV_DEVICE_REG_STATUS_ASSIGNING                                               
    Registration Information received from service:, deviceId: riot-device-cert

Individual enrollment: The corresponding device with the Device ID (for example, “artik_device_2”) can be found in the Azure IoT Hub resource.

Group enrollment: The Device ID in this case will be the name of the leaf certificate present with the application.

Note: If there exists an Individual enrollment for the certificate, then it takes priority over Group enrollment. If trying Individual and Group enrollment with the same certificate (the Private key is the same with the application that comes with the SDK), delete the individual enrollment in Device Provisioning Service and then run the prov_dev_client_sample application to create an IoT device in the Azure IoT Hub.

Last updated on: