0

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.

2 Answers2

0

I have referred this MSDOC Azure Digital Twins and git

enter image description here

JSON File:

{
  "@id": "dtmi:example:Room;1",
  "@type": "Interface",
  "displayName": "Room",
  "contents": [
    {
      "@type": "Property",
      "name": "Temperature",
      "schema": "double"
    },
    {
      "@type": "Property",
      "name": "Humidity",
      "schema": "double"
    },

  ],
  "@context": "dtmi:dtdl:context;2"
}

Output:

enter image description here

Sampath
  • 810
  • 2
  • 2
  • 13
  • Yes, I am using similar querys to fetch data into my appication. What im wondering is if there is a way to specify what property that should be returned. Lets say I only need to know Humidity in your example, not interested in Temperature. – Samuel Engström Jun 08 '23 at 17:32
  • The query for Humidity in my example for [input](https://i.imgur.com/fJ2HbLf.png) , [Output](https://i.imgur.com/3dibdVZ.png) [Output2](https://i.imgur.com/vn0E1X9.png) for more details refer [link](https://learn.microsoft.com/en-us/azure/digital-twins/quickstart-azure-digital-twins-explorer) and git provided above – Sampath Jun 09 '23 at 01:03
  • Im sorry if im not making myself understood. Is it possible to just fetch a specific value using the ADT API from a Twin. My problem is that I have 100 parametes, I want to poll one of the parameters from the twin every few secounds. So instead of fetching all 100 parameters witch is quite a lot of data in my use case, I only get the one value. – Samuel Engström Jun 14 '23 at 12:02
  • Yes, the docs are does not awnser my question eather. I have contacted Microsoft direcly and will update this thread when I have more info. – Samuel Engström Jun 19 '23 at 15:30
0

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