Windows IoT Documentation

Stream Analytics with Azure IoT Hub

Azure Stream Analytics (ASA) enables real‑time analytics on data streams from your IoT devices. When combined with Azure IoT Hub, you can ingest telemetry at scale, apply complex event processing, and output results to storage, dashboards, or downstream services.

Key Concepts

  • Input: IoT Hub acts as the input source for ASA. Each device can send telemetry that ASA consumes.
  • Query: ASA queries are written in a SQL‑like language to filter, aggregate, and join streams.
  • Output: ASA can route processed data to Azure Blob Storage, Power BI, Event Hubs, or custom endpoints.

Sample ASA Query


SELECT
    DeviceId,
    System.Timestamp AS EventTime,
    AVG(temperature) AS AvgTemp,
    MAX(humidity) AS MaxHumidity
INTO
    [PowerBIOutput]
FROM
    IoTHubInput TIMESTAMP BY eventEnqueuedUtcTime
WHERE
    temperature > 0
GROUP BY
    DeviceId,
    TumblingWindow(minute, 5)

This query computes a 5‑minute sliding average temperature and maximum humidity per device, then ships the results to a Power BI dashboard.

Step‑by‑Step Setup

  1. Provision an Azure IoT Hub resource.
  2. Create a Stream Analytics job.
  3. Configure IoT Hub as the job's input (choose "IoT Hub" > "Event Hub-compatible endpoint").
  4. Define your query (see example above).
  5. Add an output (e.g., Power BI, Blob Storage).
  6. Start the job and monitor via the ASA portal.

Resources & References

Discussion