Microsoft Azure – Introduction to Azure Digital Twins
In this article, we will learn how to get started with Azure Digital Twins. With Azure Digital Twins, you can model your real-world environment, including buildings, IoT sensors, and people to keep track of it, monitor it, and design it.
Let’s see how that works. First, we need to create an Azure Digital Twins service in Azure. Let’s search for Digital Twins and Create it.
Then we’ll select a resource group, and we’ll leave the location as it is. Finally, let’s fill in a name for the service and create it.
The Azure Digital Twins service exposes API endpoints that we are going to use in a sample application.
To be able to use it, we need access to the service. We’ll do that here, and we will need to add a role assignment. We need the role Azure Digital Twins Data Owner, and we’ll assign it to ourselves.
In this article, we’ll use a sample application to work with Digital Twins called the Digital Twins Explorer. You can download it from this URL.
Also, you need to have Node.js installed on your local machine. You also need the Azure CLI.
Once you’ve downloaded and unzipped the sample application, navigate to the client folder and then to the source. You need to open that path in a command window like as shown below:
Now run the below command to install the npm modules that the app needs.
When that is done, use the below command to run the application.
npm run start
This opens the app in a browser, and it looks like this.
First, we need to connect to the Azure Digital Twins using this button at the top and enter the URL, which is the service’s hostname, with HTTPS in front of it.
We can use this app to create a design of a real-world environment using Digital Twins. This starts with modal definitions, which describe things like sensors, people, or structures of your environment. We can import modules with the below-shown button.
There are some predefined ones in the sample app folder. You can create these models with a JSON-like language called the Digital Twin Definition Language.
For instance, these are definitions of a floor and a room.
Now we can create an environment with these using the twin graph. You can create a graph definition yourself and upload it using the below-shown button.
The sample app already contains a definition here. Let’s save it, so it uploads to Azure.
Now, we can run a query against the twin graph in Azure to retrieve the information. This is a representation of a real-world environment containing two floors that each contain a room. Each one is a Digital Twin, which you can create with the modal definitions.
When we click on one, we can see its properties as shown below:
This room has properties like temperature and humidity. We can also create a different query to answer questions about our environment. In this example, the temperature doesn’t come from a real device. But you can integrate real-world data into the graph so that your graph is up-to-date with the actual environment. You can also edit properties of a Digital Twin manually.