Create an IOT Hub (via Azure Portal), Authenticate using a Raspberry Pi
Tags: iot, beginners, devops, opensource
Published: 2023-12-13 05:30:19

_Need to create an IOT HUB ?_

_Trying to authenticate a connection to an IoT device using a Raspberry Pi device simulator?_

Let's create one together... First, let's try to understand what Azure IOT is.

##**What is Azure IOT Hub ?**

Azure IoT Hub is a cloud service within Microsoft Azure that facilitates secure and scalable communication between IoT applications and the devices they manage. Azure IoT Hub provides a cloud-hosted solution back end to connect any device virtually.

It seamlessly integrates with other Azure services, allowing developers to build end-to-end solutions, and provides monitoring and diagnostics capabilities for tracking solution health and performance. 

_Now create an Azure IOT HUB via Azure portal using these basic steps:_



**Step 1:**

Log in to the Azure portal, Locate virtual Machine on the Azure portal and create


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1g0io0ov949j8cg1jer.png)




**Step 2:** 

Search or Locate IOT Hub  on the list of resources from the category "Internet of things"



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfq73z2hxoxumaicfwxd.png)





**Step 3:**

_For the Basics Category;_

**Under Project details (resource group )**- I will use an existing resource group "Decemberworkload" but if you don't have one create a new resource group and name it.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4xu0obbf1fpk62eokud.png)






**Step 4:**


Under Instance details - we have to name the IOT HUB

"Teehub"

Region: East US
Tier : Standard
Daily message limit : 400,000


_**THEN - REVIEW AND CREATE**_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o65424ccnwrto5inviyz.png)





**Step 5:**

You will get the full details of the resource - Click the 'Create button'


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98i1inirc62r22ddlkf9.png)




**Step 6:**

Give the deployment time to be completed.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rll0mcwycy7c81yowfs2.png)




**Step 7:**

Deployment is complete, Click on 'Go to resource'


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5ibjyyaxui9379qbnw8.png)




**Step 8 :**

Take note of the IOT HUB Usage


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1qqo6fs6qnc4gkxc0h9p.png)



_**Now we will be registering a new device in the Azure IoT hub**_


Go back to the home page and search for IOT hub, you will see the hub that was just created. click on it






**Step 9:** 

On the left hand panel , under device management, click on devices - then add a new device


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bi3bgb41fm74fxn0cdvf.png)








**Step 10 :**

Create a Device ID - Then 'click on save' to save


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rspvyq3lqy8w0ub9jlg3.png)









**Step 11 :**

Once the device is created successfully, click on it to view.

Then go ahead to copy the 'primary connection'. Make sure to use the copy icon.









**Step 12:**

Go to the [Azure raspberry pi simulator web page](https://azure-samples.github.io/raspberry-pi-web-simulator/),go ahead to replace the string on line 15 with the one we copied in step 11.






**Step 13:**

Click on 'run' to run the command


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/koi8rkyzkgdyv6656367.png)








**Step 14:**

Once you run with the primary connection string. The red light beeps and that shows you have successfully added a new device and authenticated a connection.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyi9pzdpdcex5ll3iyh2.png)














## **_Yippee🎉and Well done Mate👌_**













![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb577fiokoesag6nrvsr.png)