zmoog / til

Today I Learned
MIT License
3 stars 0 forks source link

Learn about Azure IoT Hub — part 1 #9

Closed zmoog closed 1 year ago

zmoog commented 1 year ago

Learn about IoT Hub from Azure by building a small project to collect data from some devices.

zmoog commented 1 year ago

Let's start from a tutorial from Microsoft docs: Quickstart: Send telemetry from a device to an IoT hub and monitor it with the Azure CLI.

This is a codeless tutorial, where device is simulated using the Azure CLI.

zmoog commented 1 year ago

We need to install a CLI extension:

$ az extension add --name azure-iot
zmoog commented 1 year ago

Create a resource group for this project:

$ az group create --name zmoog-iot-hub --location eastus
$ az iot hub create --resource-group zmoog-iot-hub --name zmoog-iot-hub
zmoog commented 1 year ago
# This command creates the simulated device identity.
$ az iot hub device-identity create -d device0 -n zmoog-iot-hub

# This command starts the simulated device. The device sends telemetry to your IoT hub and receives messages from it. 
$ az iot device simulate -d device0 -n zmoog-iot-hub

# This command continuously monitors the simulated device. The output shows telemetry such as events and property state changes that the simulated device sends to the IoT hub.
$ az iot hub monitor-events --output table -p all -n zmoog-iot-hub
zmoog commented 1 year ago

This is interesting. I created a device and executed some simulated activities using the CLI only.

CleanShot 2022-12-20 at 23 16 52@2x

zmoog commented 1 year ago

Clean up resources:

$ az group delete --name zmoog-iot-hub
zmoog commented 1 year ago

The tutorial also have additional sections:

But currently I am not interested.