Prerequisites: Approvals on Runtime Agent. Azure IoT Hub connection string and device ID.
Build an IoT Hub alert handler from template #16 with a safety gate before sending a cloud-to-device (C2D) command — ideal for export to a runtime agent where operators approve on the local dashboard.
What this template does
- Receive D2C Message — device-to-cloud from IoT Hub.
- Is Alert Message? — condition on alert status.
- Alert Detected — warning notification.
- Send C2D Acknowledgement — marked Dangerous — requires operator approval at runtime.
Step 1 — Load the template
- Studio → Templates → search
Azure IoT Hub Message Handler. - Load template #16.
Step 2 — IoT Hub settings
- Configure connection string and
deviceIdon receive and send nodes. - Set C2D payload in Send C2D Acknowledgement.
- Add Cron or Webhook trigger upstream if needed.
Step 3 — Export to runtime
- Activate and Export Runtime.
- Enable Operator approval support — required for Dangerous
iothub.send. - Install on gateway with outbound access to Azure IoT Hub.
Step 4 — Safety approval on agent
- Simulate or receive a D2C alert message.
- Run suspends at Send C2D Acknowledgement.
- Operator opens
http://localhost:9090(or LAN URL with token). - Approve with operator name — C2D message sends only after confirmation.
- If denied or timeout, no C2D command is sent.
Why safety gate here?
C2D commands can change device behavior in the field. The Dangerous classification forces a human checkpoint — separate from business approvals in /approvals.
Related tutorials
- Approved Device Command (#8) — Z-Wave safety gate.
- Approvals on Runtime Agent
- Approval & Arm Gates