Azure IoT Hub – Overview & Getting Started
The Azure IoT Hub is a fully managed service that enables reliable and secure bi‑directional communication between your IoT devices and the cloud. It's the cornerstone for building scalable IoT solutions on Azure, providing device provisioning, management, and telemetry ingestion.
Key Features
- Device-to-cloud telemetry at massive scale
- Cloud-to-device messaging with guaranteed delivery
- Per‑device authentication using X.509 certificates or symmetric keys
- Device provisioning service (DPS) for zero‑touch onboarding
- Built‑in integration with Azure Stream Analytics, Functions, and Time Series Insights
Quick Start with Windows IoT Core
Follow these steps to connect a Windows IoT Core device to Azure IoT Hub.
1. Create an IoT Hub
az iot hub create --resource-group MyResourceGroup --name MyIoTHub --sku S1
2. Register a Device Identity
az iot hub device-identity create --hub-name MyIoTHub --device-id MyWinIoTDevice
3. Get the Device Connection String
az iot hub device-identity show-connection-string --hub-name MyIoTHub --device-id MyWinIoTDevice --output table
4. Install the Azure IoT SDK
dotnet add package Microsoft.Azure.Devices.Client
5. Send Telemetry from the Device
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
class Program
{
static async Task Main()
{
var connectionString = "";
var deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Mqtt);
while (true)
{
var telemetry = new { temperature = 23.5, humidity = 60 };
var message = new Message(Encoding.UTF8.GetBytes(System.Text.Json.JsonSerializer.Serialize(telemetry)));
await deviceClient.SendEventAsync(message);
Console.WriteLine("Telemetry sent");
await Task.Delay(5000);
}
}
}
Replace <YOUR_DEVICE_CONNECTION_STRING> with the string obtained in step 3.
Next Steps
- Explore Security best practices
- Implement Device Provisioning Service
- Integrate with Azure Stream Analytics
Comments