Reader small image

You're reading from  The Azure IoT Handbook

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781837633616
Edition1st Edition
Right arrow
Author (1)
Dan Clark
Dan Clark
author image
Dan Clark

Dan Clark is a senior developer and data engineer specializing in Microsoft technologies. He is focused on learning new AI and data technologies and training others on how to best implement those technologies. He has worked as an Azure Technical Trainer (ATT)for Microsoft and has over 25 years of experience as a Microsoft Certified Trainer. Dan has published several books and numerous articles on Microsoft technologies. He is a regular speaker at various developer and database conferences and user group meetings and enjoys interacting with the Microsoft communities.
Read more about Dan Clark

Right arrow

Lab – setting up an IoT hub in Azure

By the end of this lab, you will be able to do the following:

  • Navigate the Azure portal
  • Set up a resource group
  • Create an IoT hub
  • Create a virtual device
  • Send data from the device to the IoT hub

To do this, you will need to perform the following steps:

  1. Before you start the lab, you will need to create a unique ID. We will add this to the ends of your resource names to make them unique. This ID can be whatever you want. I find using my initials and then attaching the month and day I was born works well. So I would use drc0830.
  2. Open a Microsoft Edge browser window, and then navigate to the Azure portal (https://portal.azure.com).
  3. Sign in with the credentials you used to create the account. You should land on the home page. You can customize the look and feel by selecting the settings icon in the top-right corner:
Figure 1.3 – Selecting the settings icon

Figure 1.3 – Selecting the settings icon

  1. On the settings page, select the Appearance + startup views tab. Make sure the Menu behavior option is set to Docked (see Figure 1.4). Also, verify that the startup page is set to Home.
Figure 1.4 – Setting up the look and feel of the portal

Figure 1.4 – Setting up the look and feel of the portal

  1. Via the left-side menu, go back to the Home page.
  2. At the top of the page, you should see a + icon that lets you create a resource. Click on it, and in the search bar that appears, enter Resource group, then select Resource group from the results dropdown:
Figure 1.5 – Creating a resource group

Figure 1.5 – Creating a resource group

  1. On the next page, click on the Create button to start the creation of the resource group.
  2. In the Basics tab, create a resource group named rg-iot-training-{your-id} (replacing {your-id} with the one you created earlier). Select a region close to your location and then select Review + create at the bottom:
Figure 1.6 – Creating a resource group

Figure 1.6 – Creating a resource group

  1. Once it passes validation, click on the Create button at the bottom of the page.
  2. After your new resource group has been created, select Resource groups in the menu on the left. You should see the resource group you just created in the list. Select your resource group from this list.
  3. At the top of the resource group page, select the + Create button. This brings you back to the Azure Marketplace. Search for and create an IoT hub. Name the hub iothub-{your-id}. Select the same region as that of the resource group you created.
  4. Select Review and create at the bottom of the page. Once it passes validation, select Create. Once it is created, click the Go to resource button.
  5. Investigate the features of the IoT hub using the left-side menu.
  6. From the menu on the left, select Devices. On the Devices page, select Add Device.
  7. Name the device device01, leave the rest of the settings as the defaults, and select Save:
Figure 1.7 – Creating an IoT device

Figure 1.7 – Creating an IoT device

  1. You may have to refresh the page to see the device just created in the device list. Once the device has been created, select it from the list. Copy and save the Primary connection string value for the device.
  2. In order to simulate a device, we are going to use the Raspberry Pi Azure IoT simulator. You can get access to it by going to https://azure-samples.github.io/raspberry-pi-web-simulator/.
  3. Go to line 15 in the code and paste the device connection string you copied earlier:
Figure 1.8 – Updating the connection string

Figure 1.8 – Updating the connection string

  1. Select Run and verify messages are being sent.
  2. Go back to the Azure portal and navigate to your IoT hub. On the Overview page, verify that you are getting signals from the simulated device. From the list labeled Show data for last, select 1 Hour:
Figure 1.9 – Verifying messages in the IoT hub

Figure 1.9 – Verifying messages in the IoT hub

  1. Once satisfied you are getting signals, stop the simulated device and close the web page.

Now that we are done with this chapter, let’s summarize what we have learned so far and where we are going next.

Previous PageNext Page
You have been reading a chapter from
The Azure IoT Handbook
Published in: Dec 2023Publisher: PacktISBN-13: 9781837633616
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Dan Clark

Dan Clark is a senior developer and data engineer specializing in Microsoft technologies. He is focused on learning new AI and data technologies and training others on how to best implement those technologies. He has worked as an Azure Technical Trainer (ATT)for Microsoft and has over 25 years of experience as a Microsoft Certified Trainer. Dan has published several books and numerous articles on Microsoft technologies. He is a regular speaker at various developer and database conferences and user group meetings and enjoys interacting with the Microsoft communities.
Read more about Dan Clark