Hands-on Azure Digital Twins Read Online !!top!! Link
# 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"
Your graph is now alive. Think of it as a mini-Google Knowledge Graph for your warehouse. Unlike SQL (tables) or NoSQL (documents), ADT uses a graph query language similar to SQL but with RELATED and IS_OF_MODEL . Query 1: Find all sensors in the Receiving Zone az dt twin query --adt-name adt-warehouse-<unique> \ --query-command "SELECT sensor FROM digitaltwins zone JOIN sensor RELATED zone.hasSensor WHERE zone.\$dtId = 'ZoneReceiving'" Result: Returns TempSensor-Rcv . Query 2: Traverse two hops (Warehouse → Zone → Sensor) az dt twin query --adt-name adt-warehouse-<unique> \ --query-command "SELECT sensor, zone FROM digitaltwins wh JOIN zone RELATED wh.contains JOIN sensor RELATED zone.hasSensor WHERE wh.\$dtId = 'WarehouseMain'" This is powerful. In a real app, this query would run in milliseconds, even across 100,000+ nodes. Step 6: Simulate Telemetry and Compute Changes Here’s where it gets truly hands-on. Azure Digital Twins itself does not ingest telemetry directly. Instead, you use Azure Functions or IoT Hub to route data in. hands-on azure digital twins read online
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 . # Warehouse contains Zones az dt twin relationship
# --- 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']") Query 1: Find all sensors in the Receiving
# 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"