How to get DTDL of complete Digital Twin setup?

Domagoj Bazina 221 Reputation points
2022-08-25T11:38:49.67+00:00

Greetings everyone,
I'm wondering, is there any way to get DTDL of the complete Digital Twin setup, the one that includes Digital Twin instances and relationships?
I know there is a python SDK library to manage Digital Twin resource, but I can't find a single command/method to fetch complete DT setup.

There is an example (https://learn.microsoft.com/en-us/azure/digital-twins/how-to-query-graph) where you can get all digital twin instances by using query commands, or to get relationships based on Digital Twin instances. In order to get a complete setup, I would have to make several requests and combine them together.

Thanks in advance

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
219 questions
0 comments No comments
{count} votes

Accepted answer
  1. Matthijs van der Veer 4,376 Reputation points MVP
    2022-08-25T15:24:49.677+00:00

    There is no single command that will get the complete content of the Digital Twin graph. However, you can do it by making multiple calls through the SDK. The approach is as follows:

    Query all the twins

    query_expression = 'SELECT * FROM digitaltwins'  
    query_result = service_client.query_twins(query_expression)  
    

    Loop through the results and get the Incoming or Outgoing relationships for each twin.

    service_client.list_relationships(digital_twint_id)  
    

    You can also get all the models through the SDK

    listed_models = service_client.list_models()  
    

    There's documentation for the Python SDK

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful