Azure Digital Twins - Properties, Components, and Relationships

Christopher Sasso 1 Reputation point


I am attempting to create a basic model to familiarize myself with working in Azure Digital Twins.

This model contains three parts:

  1. Push Button
  2. Programmable Logic Controller (PLC)
  3. LED Light

The push button would send a signal to the PLC which would then send a signal to the LED Light to turn on.

How would I best represent this scenario?

What properties should be set to represent the push button and LED light?
For the LED light, I was thinking of using a luminosity property, but I am unsure if this is the appropriate one.

Thanking you 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.
217 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,376 Reputation points

    Hello @Christopher Sasso , welcome to Microsoft Q&A and thank you for posting your question.

    I understand you are trying to get familiar with Azure Digital Twins and for the use case you stated here, you can monitor the status of the LED light on the Azure Digital Twin by just creating a model with a single "boolean" property. The boolean property reflects the state of the LED light. You can set this property as "writable" during creation and can modify this property value through the code or Azure Digital Twin Explorer.

    Here is the JSON snippet I have used to generate the Azure Model.
    "@id": "dtmi:com:example:LightUp;2",
    "@type ": "Interface",
    "displayName": "LightPLC2",
    "contents": [
    "@type ": "Property",
    "name": "setLightStatus",
    "writable": true,
    "schema": "boolean"
    "@Георгий Георгиевский ": "dtmi:dtdl:context;2"

    You can then create the Azure Model using the JSON by using the code specified in the following tutorial - Coding with the Azure Digital Twins SDK Here is the code snippet for your reference.

                string adtInstanceUrl = "https://<your-Azure-Digital-Twins-instance-hostName>";  
                var credential = new DefaultAzureCredential();  
                var client = new DigitalTwinsClient(new Uri(adtInstanceUrl), credential);  
                Console.WriteLine($"Service client created – ready to go");  
                Console.WriteLine($"Upload a model");  
                string dtdl = File.ReadAllText("<YourModelFileName>.json");  
                var models = new List<string> { dtdl };  
                // Upload the model to the service  
                    await client.CreateModelsAsync(models);  
                    Console.WriteLine("Models uploaded to the instance:");  
                catch (RequestFailedException e)  
                    Console.WriteLine($"Upload model error: {e.Status}: {e.Message}");  
                AsyncPageable<DigitalTwinsModelData> modelDataList = client.GetModelsAsync();  
                await foreach (DigitalTwinsModelData md in modelDataList)  
                    Console.WriteLine($"Model: {md.Id}");  

    Please make sure to modify the instance URL and the file name in the above code.

    Once you have the Azure Model created, you can then generate Azure Digital Twins based on the Model using the following code snippet.

                var twinData = new BasicDigitalTwin();  
                twinData.Metadata.ModelId = "dtmi:com:example:LightUp;2";  
                twinData.Contents.Add("setLightStatus", true);  
                    twinData.Id = "Lightup2";  
                    await client.CreateOrReplaceDigitalTwinAsync<BasicDigitalTwin>(twinData.Id, twinData);  
                    Console.WriteLine($"Created twin: {twinData.Id}");  
                catch (RequestFailedException e)  
                    Console.WriteLine($"Create twin error: {e.Status}: {e.Message}");  

    You can now view the Azure Digital Twin created through the Azure Digital Twin Explorer.

    Please find the below image to refer the Azure Digital Twin I have created and the properties I see from it on the Azure DigitalTwin Explorer portal.


    You can further use the resources provided in this tutorial Manage digital twins to update or get values out of your Azure Digital Twins.

    Please let me know if you have any further questions or need further clarification on this issue.

    0 comments No comments