Azure Digital Twins Read Online [hot] - Hands-on

# Upload models az dt model create --adt-name adt-warehouse-<unique> \ --models models/*.json az dt model list --adt-name adt-warehouse-<unique> -o table

# Update the twin property patch = ["op": "replace", "path": "/temperature", "value": new_temp] service_client.update_digital_twin(sensor_id, patch)

Azure Digital Twins (ADT) gives that data context . It knows that Sensor 47 belongs to Room 312 , which is on the North Wing of Floor 3 , and that room contains a Server Rack . If the temperature rises, ADT understands the impact . hands-on azure digital twins read online

# Warehouse contains Zones az dt twin relationship create --adt-name adt-warehouse-<unique> \ --twin-id "WarehouseMain" \ --relationship-id "rel-wh-to-rcv" \ --relationship "contains" \ --target "ZoneReceiving" az dt twin relationship create --adt-name adt-warehouse-<unique> --twin-id "ZoneReceiving" --relationship-id "rel-zone-to-shelf" --relationship "contains" --target "ShelfA" Zone has Sensor az dt twin relationship create --adt-name adt-warehouse-<unique> --twin-id "ZoneReceiving" --relationship-id "rel-zone-to-temp" --relationship "hasSensor" --target "TempSensor-Rcv"

The Problem: You have a building, a factory, or a logistics center. Sensors are streaming data, but the data is "dumb"—it’s just a timestamp and a number. A temperature of 22°C in isolation means nothing. # Upload models az dt model create --adt-name

We’ll simulate a temperature spike and compute a "high temperature" alert using a . Architecture Pattern: IoT Device → IoT Hub → Azure Function → ADT (patch property) The Function Logic (Python example): import json import logging import azure.functions as func from azure.digitaltwins.core import DigitalTwinsClient from azure.identity import DefaultAzureCredential def main(event: func.EventHubEvent): # Parse telemetry from IoT device telemetry = json.loads(event.get_body().decode('utf-8')) sensor_id = telemetry['sensorId'] new_temp = telemetry['temperature']

# Connect to ADT credential = DefaultAzureCredential() service_client = DigitalTwinsClient(credential, "https://adt-warehouse-<unique>.api.eus.digitaltwins.azure.net") # Warehouse contains Zones az dt twin relationship

"@id": "dtmi:handsOn:Zone;1", "@type": "Interface", "displayName": "Zone", "contents": [ "@type": "Property", "name": "temperature", "schema": "double", "writable": true , "@type": "Relationship", "name": "contains", "target": "dtmi:handsOn:Shelf;1" , "@type": "Relationship", "name": "hasSensor", "target": "dtmi:handsOn:Sensor;1" ]