Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

Registering a Device with Azure IoT Hub

An Azure IoT Hub by itself isn't much of an IoT solution. As a matter of fact, it isn't one at all. Without devices to send telemetry to the IoT hub, the hub itself is like an ice cream shop with zero flavors. In this hands-on lab, we will create a device in a pre-provisioned Azure IoT hub and then, using a Raspberry Pi simulator, connect that device to our IoT hub. We will then be able to see connectivity between the device and our hub.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Apr 24, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Register the Device with the IoT Hub

    1. Access the CLI by using Azure Cloud Shell, logging in with the credentials provided in the lab.

    2. Click the Cloud Shell icon (>_) in the upper-right of the screen.

    3. Click Bash.

    4. Click Show advanced settings, and set the following values:

      • Subscription: Leave default
      • Resource group: Use Existing
      • Cloud Shell region: Use the same region as your lab provided storage account.
      • Storage account: Use existing
      • File share: Create new, and enter cloudshell
    5. Click Create storage.

    6. Install the Azure IoT extension for CLI:

      az extension add --name azure-iot
      
    7. Register the device (XXXXX is the five-character suffix for the lab resources):

      az iot hub device-identity create --device-id IoTDevice1 --hub-name iothub-XXXXX
      
    8. Obtain the connection string for the device (XXXXX is the five-character suffix for the lab resources):

      az iot hub device-identity connection-string show --hub-name iothub-XXXXX --device-id IoTDevice1 --output table
      
    9. Copy this connection string to your clipboard.

  2. Challenge

    Configure the Raspberry Pi Azure IoT Online Simulator

    1. Access the simulator at https://azure-samples.github.io/raspberry-pi-web-simulator/.

    2. Change the following line (line 15), replacing the text between the single quotes with the connection string you copied in the previous objective:

      const connectionString = '[Your IoT hub device connection string]';
      
  3. Challenge

    Verify Connectivity to the IoT Hub

    In the Raspberry Pi Azure IoT Online Simulator, click Run. If the previous objective was performed correctly, the "LED" light will blink, and you should see messages from the "device" being sent to the IoT hub, like so:

    IoT Device Connected!

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans