Search code examples
azureazure-digital-twins

Query Azure Digital Twins for specific parameters


I am using using Azure Digital Twins, I would like to query the twin to only return properties that is currently relevant for me.

I can get all data for a specific twin using the API GetByID or query usign the string SELECT * FROM DIGITALTWINS Twins WHERE Twins.$dtId = 'xxx'

Each of my twins have around 50-100 properties, but most of the time I am only interested in two or three of the properties. So it feels unnecessary to use the API or Query string above that fetches all propertys.

So is there a way to specify what properties that should be returned when getting twin data from ADT?

Thanks in advance!

Have looked thru the ADT documentation withoth finding an answer to my question. Expecting to find a way to pull specific property values from a twin in ADT.


Solution

  • You can certainly fetch individual properties from a Azure Digitial Twin using a query in the following format

    SELECT T.<Property1>, T.<Property2> FROM digitaltwins T where $dtId = '<TwindID>'
    

    Note that, if you are performing a query and fetching individual properties, i.e. any query other than SELECT *, the returned result cannot be displayed as a Twin graph. You can view the result of the query in the form of JSON from the Output panel. The Output panel is hidden by default and can be enabled from settings icon on your Azure Digital Twin Explorer page. Refer the below image for details.

    enter image description here

    Here is the output generated from executing a query on a Digital Twin that extracts a single property.

    enter image description here