Hands-on Azure Digital Twins Read Online -
# 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
You can do this via Azure CLI , REST API , or Azure Digital Twins Explorer . Let's use the CLI for automation. hands-on azure digital twins read online
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'] # Upload models az dt model create --adt-name
# --- Compute Logic --- # If temp > 30C, find the parent Zone and mark it as "overheated" if new_temp > 30.0: # Query to find parent Zone query = f"SELECT zone FROM digitaltwins zone JOIN sensor RELATED zone.hasSensor WHERE sensor.$dtId = 'sensor_id'" zones = service_client.query_twins(query) for zone in zones: # Add a computed property zone_patch = ["op": "add", "path": "/alert", "value": "Overheating"] service_client.update_digital_twin(zone['$dtId'], zone_patch) logging.info(f"Alert set on zone zone['$dtId']") Architecture Pattern: IoT Device → IoT Hub →
# Create twins az dt twin create --adt-name adt-warehouse-<unique> \ --dtid "WarehouseMain" \ --dtmi "dtmi:handsOn:Warehouse;1" az dt twin create --adt-name adt-warehouse-<unique> --dtid "ZoneReceiving" --dtmi "dtmi:handsOn:Zone;1"
# Connect to ADT credential = DefaultAzureCredential() service_client = DigitalTwinsClient(credential, "https://adt-warehouse-<unique>.api.eus.digitaltwins.azure.net")
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.