Hands-on Azure Digital Twins

By Alexander Meijers

Early Access

This is an Early Access product. Early Access chapters haven’t received a final polish from our editors yet. Every effort has been made in the preparation of these chapters to ensure the accuracy of the information presented. However, the content in this book will evolve and be updated during the development process.

Learn more
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. 1 About Digital Twins

About this book

In today’s world, clients are using more and more IoT sensors to monitor their business processes and assets. Think about collecting information like pressure from an engine to the temperature and light switch being turned on or off in a room. The data collected can be used to create smart solutions for predicting future trends, creating simulations, and drawing insights using visualization. This makes it beneficial for organizations to make digital twins, which are digital replicas of the real environment, to support these smart solutions.

This book will help you understand the concept of a digital twin and how this can be implemented using an Azure service called Azure Digital Twins. Starting with the requirements and installation of the Azure Digital Twins service, the book will explain the definition language used for modeling digital twins. From there, you'll go through each step of building digital twins using Azure Digital Twins and learn about the different SDKs and APIs and how to use them with several Azure services. Finally, you'll understand how digital twins can be used in practice with the help of several real-world scenarios.

By the end of this digital twin book, you'll be confident in building and designing digital twins and integrating them with various Azure services.

Publication date:
February 2022
Publisher
Packt
Pages
396
ISBN
9781801071383

 

1 About Digital Twins

This chapter will explore the concept of a Digital Twin. A Digital Twin is a virtual representation of the real world combined with real-world data. Digital Twins can be used for a variety of scenarios. Digital Twins can be used to visualize insights or to simulate real-life situations by using a virtual representation and real-life sensory data. Learning about Digital Twins allows you to build solutions around these scenarios.

In this chapter, we’ll go through several scenarios to understand Digital Twin implementations. We’ll look at Microsoft’s Azure Digital Twins service and how it allows us to model a Digital Twin. We’ll walk through the layout of the service and how it is incorporated into the model of a Digital Twin. Part of that is a global overview of the architecture, which includes the relationship to other Azure services. This is required to create an actual Digital Twin solution. We will finish with an overview of the available SDKs and APIs for using Azure Digital Twins to create your own Digital Twin solutions. The chapter contains a lot of introductions to different services and tools that will appear again in the following chapters.

In this chapter, we’ll go through the following topics:

  • Understanding the concept of the Digital Twin
  • Exploring the Digital Twin environment
  • Looking at real-world applications
  • Azure Digital Twins
  • Understanding the components of Azure Digital Twins architecture
  • Exploring Azure Digital Twins APIs
 

Understanding the concept of a Digital Twin

You have probably heard someone talking about Digital Twins in the last few years. You could even say that it has been a buzzword for some time. But since 2019-2020, it’s become more than just a buzzword. Organizations and people have started to understand the benefits of having a Digital Twin. There has even been a large increase in organizations that want to start and implement a Digital Twin.

But what is a Digital Twin? I get that question a lot. And every time it is difficult to come up with an answer that others will understand. And even referring to the definition on Wikipedia will not make it easy to understand. There are a lot of different definitions you can find online in articles and blog posts. To explain what a Digital Twin is requires a definition to start with followed by a more in-depth explanation of the definition itself. I use the following definition:

A Digital Twin is a digital replica of entities and their relationships in a reality

You may have noticed that this definition contains several terms: digital replica, entities, and reality. It becomes clearer when explaining each of them in more depth.

Digital replica

A digital replica is a way of storing several entities and their relationships in a specific model. Such a model is stored in a location according to your requirements and needs. An example could be a database or service. Each product on the market that is available to create a Digital Twin has its own way of storing the information that describes the model. That means that the digital replica can describe a real-life situation using definitions and parameters. Think of a machine and whether it is turned on or off. The digital replica would describe the machine and its state. But a digital replica could also be about a collection of machines and their relationships. Think of a machine that is creating a product and the machine that is packing the product. The packing machine requires products to pack anything. That relationship is also described in a digital replica.

Entities

Entities can be different things. An entity can be anything from a physical living being such as people to a physical non-living thing such as processes, machines, buildings, equipment, rooms, and devices. When we talk about physical, it means being physically part of the reality from which you create a digital replica. Each of these entities has a specific purpose within the model. An entity is described by its characteristics that are relevant to the model and what you try to achieve in your solution. An entity could be a temperature sensor installed in a room. The characteristics are then the location of that sensor, the temperature the sensor is measuring, and the notifications it is raising when the temperature gets too low or too high. The location in this case is the room where the sensor is located. That characteristic is a relationship to another entity called the room. All these characteristics when developing Digital Twins are described by properties and metadata.

Relationships

An important part of a Digital Twin is the way entities are related to each other. These relationships are important as they define the context in which the entities are depending on each other and are a part of the reality on which the model is based. A relationship itself defines a set of data based on how the relationship is defined between the entities. An example is the relationship between the temperature sensor and the room where it is installed. This relationship defines what the temperature is within the room. Business rules can be used to take certain actions based on entities and their underlying relationships. An example would be switching off the lights within the room when there is no movement for a pre-defined time. In that situation, the lights, motion sensor, and room are each an entity with underlying relationships.

Realities

Each entity is part of a reality. Normally the reality would be a part of the physical world around us, like the example of the temperature sensor in a room. In that case, we have an actual device, room, and building. But imagine a world that represents a theoretical reality. This could be a virtual, generated reality that acts as the source for the digital replica. An example would be a digital world created in virtual reality or even another Digital Twin.

You have just learned about the concept of Digital Twins and its elements. This is important since it will help you to understand how Digital Twins can be applied to different scenarios. In the next section, we will explore the different parts of the environment around a Digital Twin to implement Digital Twin solutions.

 

Exploring the Digital Twin environment

It is important to understand that we need to do more than just store a model of entities to use a Digital Twin. Using a Digital Twin requires us to bind information to our entities in the model and use some method of visualization to view the model and its outputs.

Figure 1.1 – High-level overview of a Digital Twin environment

The model in Figure 1.1 shows a high-level overview of everything that is in some way used within a Digital Twin environment:

  • Entities – This part represents the entities from your reality. This is, for example, real-world assets, people, processes, and locations. Data that defines these entities is stored in some way in the Digital Twin.
  • Digital Twin – This is the digital replica model of the entities in the reality.
  • Input module – This part of the model provides data from entities into the Digital Twin model. In some situations, this is also used to dynamically generate the model-based structure of the entities. It depends heavily on actual data that flows from the entities being used in the reality.
  • Output module – The output of the model is in most cases used to visualize the data in some way. But that is not always the case. The output could also be a setting turned on based on business logic and rules that are triggered by the input.
  • Business logic and Rules modules – This is all about building logic and rules around the data in your Digital Twin. The result of this logic can resolve into setting the data of entities in the Digital Twin. You could extend this by connecting to or triggering the actual entity.
  • Visualize – It is often thought that a Digital Twin is visualized. But that is not always the case. In many situations, the data flows back to the entity itself. But in some situations, a visualization of data could enhance the experience and benefit the business process. Visualization can be reached in many ways. Think of a display at the door of a meeting room displaying availability, an Excel that is filled with output data, or using augmented glasses to create a 3D presentation based on the data from the entities.
  • Security – Each module needs to have some sort of role-based security. This can influence what data flows in and out of the Digital Twin. It could be used to only view the data that you are allowed to see based on your role in the organization. But it could also be used to view a subset of output data coming from the Digital Twin.

Now let’s look at how a Digital Twin is connected to real-world entities.

A Digital Twin needs to be integrated with the physical and non-physical entities that it represents. As shown in the following figure, you will see that a Digital Twin is about being connected:

Figure 1.2 – Real-world entities are connected to a Digital Twin

Any device that can generate some form of output information based on sensors, processes, or a manual action can be an input for your Digital Twin. And these same devices, if they have some form of interface, can be controlled using rules based on the received input.

Taking the example of the motion sensor, the entity representing the motion sensor needs to get the values from the actual motion sensor in the room. Then, business logic can define that the lights need to be turned off or on based on the value within that entity. The lights themselves are also an entity in the model and bound to the actual lights within the room. The business logic can then set the value on the entity of the lights.

There are Digital Twins that require no visualization. Those Digital Twins handle and set values that will cause certain physical entities to respond. Like the example with turning on and off the lights. There are situations where a Digital Twin needs to be visualized. Such situations require some sort of presentation of the information from the Digital Twin model. Presentations can be flat out a spreadsheet or a list. But they can also be a visual representation of reality on a desktop screen. And nowadays, with extended reality using augmented glasses, it is even possible to have 3D modeled presentations of your Digital Twin.

You have learned about the different modules and parts that are required when you are going to build a Digital Twins solution. In the next part, we will be looking at several real-world examples.

 

Looking at real-world applications

In this chapter, we have several scenarios that will help you better understand the idea behind a Digital Twin and what it can contribute to an organization. Since implementing a Digital Twin can be a costly journey to implement, it is important to address the business value for organizations:

  • Gaining insights – Digital twins can be used to get better insights into your business operations and allow you to optimize these processes. More insights can be reached by visualizing situations that would normally not be visible or more difficult to understand. Hence, better insights and allowing you to respond differently, more quickly, or in a more streamlined process.
  • Collaboration – Using Digital Twins to view data in a collaborative way. By mimicking a real situation digitally, you can have multiple users experience and view the same data while not even being at the same location.
  • Education – Digital Twins give you the ability to create learning environments. These learning environments can be used at schools or at the start of a job to get new employees more quickly up to speed.
  • Simulation – Simulation by using Digital Twins allows you to create digital replicas of environments that are normally difficult to reach, too dangerous, or just not accessible. It also allows you to experiment with settings to see what the outcome is before changing these settings in the actual environment to prevent downtime or process disturbances.
  • Create experiences – Experience a process, environment, or other situation by digitizing using a Digital Twin. There is a very clear distinction for people between looking at a flat dashboard and having the situation visualized in three dimensions. People are used to understanding more quickly by looking at something in a three-dimensional way. It can also contribute to investors and management having a clearer overview of what they are managing.
  • Optimize operations and costs – Use Digital Twins to optimize processes in an organization to optimize operations and reduce costs. Digital twins can deliver a return on investment in different ways. Better insights reduce time to action, getting new employees up to speed more quickly, or simulate possible optimizations before making them available in the real world.

Smart building

A smart building involves including intelligence in the processes of maintaining a building and its services. In this example, we have the Contoso office building, which has several meeting rooms. These rooms are maintained by facilities. Since this office building is a smart building, several sensors are installed in each room. We have sensors for temperature, humidity, motion, and light. Each of these sensors can be read out through a smart network. Additionally, things such as light can also be controlled by that same smart network.

Figure 1.3 – Example of a 2D map interface used for a smart building

The facilities team is responsible for the state of these rooms. One of their responsibilities is, for example, keeping the rooms at a standard temperature. There are several conditions that can influence the temperature in the rooms:

  • Room usage – The room being used or not for a specific amount of time
  • Group size – The number of people that are in the room when it is in use
  • Devices – Devices such as laptops, wall screens, projectors, and the use of light

Another responsibility is to provide a booking system for the meeting rooms. This booking system shows the availability on a small screen at the door and allows employees to book a meeting room through an app or service, such as Outlook.

A Digital Twin can be used to monitor and act based on business logic and rules. It can automatically switch off the lights when there is no movement in the room for a specific period. It can change the temperature based on the conditions mentioned earlier. But it is also used to update the small screen at the door with the latest information and bookings, maintaining availability by freeing up rooms that were booked but do not have someone inside, since we monitor light and movement.

There are many other features that are provided by using a Digital Twin for a smart building.

Education

In this example, we are at the Contoso Water company. Water is coming in from natural sources and goes through a filter system into large reservoirs where it is transported to households. The system needs to be in harmony for optimal performance.

This water company uses large pumps that transport incoming water into the filter system. The configuration of these pumps and their throughput needs to be adjusted over time. It is a delicate task to make changes. With the wrong configurations, the filter system could be overloaded and bring the whole water plant to a stop. The engineers who are allowed to perform these tasks must have many years of experience to perform these tasks without worry.

What happens with a junior engineer who just came from school? The junior engineer needs to learn these tasks too. But you don’t want the junior engineer to practice on the actual water pump.

A Digital Twin can help with this. By replicating the important, key parts of the water plant, simulating and visualizing the assets using augmentation or virtual reality, the junior engineer can learn how to execute these tasks. The student engineer can view the digital pump and learn how to control this pump. And by tweaking the values in the model, it is possible to see the influence on the other assets in the plant. For example, by changing the throughput of the water, the student engineer can learn what the effect is on the filter system. This can be achieved by enriching the Digital Twin model using historical data and specifications of the real-world assets such as the water pump and the filter system.

Simulation

Simulation is one of the most powerful features you can create with Digital Twins. Just like the teaching example, you can simulate almost anything in a digital world. Simulation can be used for areas that are normally very dangerous to be in, such as an oil rig or areas that are not easily accessible, such as an operating room in a hospital. But it can also be used to optimize processes, which will in time create more margin.

In this example, we have the Contoso oil plant. Most of the areas in an oil plant are dangerous due to the threat of explosions and fire hazards. Oil plants contain large quantities of assets, each with its own configuration and real-time sensor devices.

For an oil plant, it is important to have the plant running as close to optimal as possible. The more oil produced, the better.

Now assume we use a Digital Twin to create a digital replica of the oil plant. We add the configuration information and real-time IoT data from sensors to the Digital Twin. This digital replica allows us now to change configuration settings for the plant and see what effect this has on oil production. Since we don’t know the results upfront, the simulation will help us decide which asset configurations are required to have a positive effect on oil production.

Historical data

An interesting use case is the ability to view historical data using a Digital Twin. The amount of data stored by organizations is phenomenal. But that data is almost never used in a way that the organization could benefit from.

For this example, we will use Contoso Events. Contoso Events is a large organizer that organizes events in big cities. One of their main concerns is handling security and safety. This involves the government, police, health, and fire department. They will need to prove that they have taken enough precautions to manage it. Contoso Events needs to determine what is required to achieve a certain level of security and safety. Part of this is closing roads and defining health points in the city. The organization uses smart cameras during the event to monitor issues and crowd density. They have been collecting this data and data from various access, check, information, and health points.

In this case, the Digital Twin is a digital replica of the city map enriched with the collected data. All data is visualized on a city map. The digital twin contains a slider to move through time to view everything that is happening during the event. Based on these insights, their own experiences, and using machine learning, they are able to determine what the best locations are for placing roadblocks, information points, access points, and health points. The information is shared with all the government agencies.

Insight and control

Having better insights into and control over processes can help an organization. It is all about empowering workers at any level, improving and optimizing processes, and getting insights and end-to-end telemetry.

We have a company called Contoso Construction. This company performs construction work on existing facilities worldwide. Their work involves adding and updating new assets. They use large equipment such as trucks and cranes to perform their work. Several workers are onsite performing different tasks to get the job done. Contoso Construction wants to have more insights and control over the work process and the safety of their employees. While they try to prevent incidents, when those incidents happen, they require a command center to monitor and assist from a global level. Each assignment they have gives them asset data. This asset data contains the location of the asset and real-time data from sensors that are connected to the asset. An asset can be anything from a simple machine to a storage location.

By combining all this data into a Digital Twin and connecting it to backend systems containing the assets, Contoso Construction can create a visual representation of the site using augmented glasses as shown.

Figure 1.4 – Command and control center of a construction site

When an issue occurs, the facility manager can view the issue in real time on a 3D map of the site. The visualization shows which alerts are generated based on sensor data and which cases and tasks are created. It is even possible to assign a task to an engineer. That data flows back into the Digital Twin and updates the connected backend systems.

You have learned about the different scenarios of using a Digital Twin. These examples have shown you how to solve scenarios around gaining insights, education, simulation, and creating experiences with Digital Twins. In the next part, we will explain how Digital Twins reside within Microsoft Azure.

 

Azure Digital Twins

Microsoft has built a comprehensive cloud platform in the last 10 years called Microsoft Azure. Every year, new services are released on the platform. One of them is Azure Digital Twins. Azure Digital Twins is part of the Internet of Things (IoT) platform and is called the next-generation IoT solution that models the real world.

The Azure Digital Twins service

The Azure Digital Twins service is a platform as a service (PaaS) that enables you to create digital replicas of an environment. PaaS is a cloud model where a provider delivers hardware and software tools enabling you to build your solutions without worrying about purchasing, installing, and maintaining hardware infrastructure.

It has a robust setup that provides a scalable and secure environment. It is part of IoT-connected solutions within Azure that allow it to connect to assets such as IoT devices as other Azure services and backend systems. The Azure Digital Twins service uses an event system to allow you to build your own business logic and data processing as routing. And it integrates with Azure services such as Azure Storage, Analytics, and Azure Machine Learning to extend the platform with predictiveness. The service can be created through the Azure portal.

Important terminology

Before we move forward, it is important to understand the different terminology used within Azure Digital Twins. Without it, it could become very confusing when explaining how Azure Digital Twins works.

  • Azure Digital Twins instance – This represents the complete digital replica of reality.
  • Model – A model is seen as the noun in a description within reality. It is like a class within programming and defines a part of that reality. Examples of a model are Room, Engineer, Asset, MotionSensor, Device. Each model is described by properties, relationships, telemetry, components, and commands.
  • Digital Twin – An instance of a model to represent a certain entity. An example is CoffeeRoom based on the Room model.
  • Twin graph – A representation of Digital Twins and their underlying relationships.

Open modeling language

Models used in Azure Digital Twins are based on the Digital Twins Definition Language (DTDL). DTDL is used as a definition language for Azure Digital Twins and IoT Plug and Play. It is part of the IoT space and helps to describe the model’s ability to support provisioning and configuration across the different IoT resources. DTDL uses a variant of JavaScript Object Notation (JSON) and is named JavaScript Object Notation for Linked Data (JSON-LD).

Important

Azure Digital Twins uses DTDL version 2. While it uses DTDL as its modeling language, it does not currently implement DTDL commands.

Tools

There are several tools that are needed when you start working on Azure Digital Twins. First, you will require an Azure environment. The Azure environment allows us to create the Azure Digital Twins service and to monitor all the other services that we will be using throughout the book.

We will be using Azure Digital Twins Explorer to view an Azure Digital Twin that is created. The tool connects to an instance of the Azure Digital Twins service and allows you to query models.

In most cases, Azure resources such as Azure Functions, Azure Service Hub, and others are used to connect to the Azure Digital Twins service. Throughout the book, we will be using Microsoft Visual Studio to create code and deploy services to build Digital Twin examples.

In most scenarios, an Azure Digital Twins instance contains digital replicas of devices. These devices generate IoT data. While normally devices are connected and routed using Azure IoT Hub, you could also make use of IoT Central.

Azure IoT Hub is a managed cloud-hosted service that operates as a message hub for bi-directional communication between an IoT application and IoT devices.

IoT Central is a web-based service that allows you to connect a variety of different devices. But it is also possible to mimic these devices. You will get the available telemetry, which instead now generates demo IoT data. This allows you easily to test your Azure Digital Twins instance without the need for actual devices.

Costs

The Azure Digital Twins service does not have any upfront cost or termination fees. You only pay for your consumption. The service has billing at three levels.

Pricing dimension Description Measurement Price calculation
Operations Each API call made to the Azure Digital Twins API counts as an operation. An operation is measured at its size part of the returned body. Each 1 KB of size is counted as a single operation. Per million messages
Messages Any message sent using event routing to an output destination using Event Grid, Event Hub, or Service Bus counts. Messages are measured in 1 KB of the payload size. Per million operations
Querying of units A query execution against the Azure Digital Twins Query API. (Each query made against the Azure Digital Twins Query API also counts as an operation.) Each query execution uses CPU, memory, and IOP resources. The return header of the query contains the number of query units consumed for that query. Per million query units

You have learned about the Azure Digital Twins service and how this represents a Digital Twin within Microsoft Azure. We also talked about the modeling language and the costs of the service. In the next part, you will learn about the different Azure components that act as input and output services when building solutions with the Azure Digital Twins service.

 

Understanding the components of Azure Digital Twins architecture

A Digital Twin Graph is created based on instances of those models and their relationships. The service provides several ways of managing the models and the Digital Twin Graph. But it depends on other Azure services to create an Azure Digital Twins instance.

Figure 1.5 – An overview of input and output services that are used with Azure Digital Twins

In Figure 1.5, you see some of the Azure services available to interact with Azure Digital Twins. Some of these services can be used for different parts of your Azure Digital Twins instance.

Managing Azure Digital Twins

Managing is all about defining and creating models, creating instances of models, and laying out relationships between those instances to create a Digital Twins Graph. To access the Azure Digital Twins service, you have REST APIs available. The creation of models is done by defining the models using the DTLD. There are several ways of managing Azure Digital Twins:

  • Azure Digital Twin Explorer – A tool to manage, view, and upload models, create instances of models, and set relationships
  • Client App – A custom application that makes use of available REST APIs and client SDKs to access the service
  • Power App – The Power Platform, a platform that provides several applications and services to build low-code/no-code solutions and allows you to create a Canvas app that can connect to an Azure Digital Twins service.
  • Azure services – Different services such as Logic Apps, Azure Functions, and Azure Service Bus provide a way of connecting to Azure Digital Twins to manage the models. We will go into more depth about these services and how to use them below.

Azure Functions

Azure Functions is a serverless compute service that runs event-triggered code. Azure Functions simplifies the development and provisioning of small applications without the concern of setting up an infrastructure. It is also called “compute on-demand.” This means that it only runs when requested and automatically upscales when the number of requests increases.

Azure Functions makes it easy to handle different roles and tasks around an Azure Digital Twins instance. The following is a list of different tasks performed by Azure Functions.

Act as Task
Input Instantiate models to create Digital Twins based on input from other systems and services.
Input Update properties and telemetry of Digital Twins.
Output Act as an API to retrieve data from a Digital Twin Graph.
Managing Set up a complete Azure Digital Twin by creating models using the DTDL notation.
Compute Use an Azure function to compute business logic and data processing. The Azure function reads from and writes to Digital Twins within the Azure Digital Twins.

Azure IoT Hub

This is a managed service that acts as a central messaging hub between devices and IoT applications such as the Azure Digital Twins service. Any device can be connected to Azure IoT Hub. The hub provides a secure way of communicating with the attached devices. It can route device telemetry to multiple endpoints. It integrates with other services such as Azure Event Grid, Azure Logic Apps, Azure Machine Learning, and Azure Stream Analytics.

In production solutions, you will mostly rely on Azure IoT Hub as the hub for connecting your application against real-world IoT sensors.

Azure IoT Hub Device Provisioning Service

This service, also called DPS, is a provisioning service for Azure IoT Hub. It enables the provisioning and connection of millions of devices in a secure and scalable way to Azure IoT Hub – scenarios such as zero-touch provisioning, load-balancing, and connecting devices to different IoT solutions within your IoT platform.

Azure Logic Apps

Azure Logic Apps is an Azure service that allows you to build automated, scalable workflows. It incorporates the basic elements of the Azure platform, such as user roles, security, and more. It supports hundreds of connectors to connect to any Microsoft service or external well-known service in the cloud or on-premises. And if there is no connector available, you can directly call the service or create your own custom connector. It provides a visual web interface allowing you to build these workflows quickly. These workflows can then be integrated into applications such as your Azure Digital Twins instance.

Azure Logic Apps can be used to define processes around your instance. These processes will be able to create and update Digital Twins. Processes can act upon certain values that are read from the Digital Twins.

Azure Storage

In principle, a Digital Twin can store information in its properties. But as soon as new values are set, the old values are overwritten. Data can be preserved by connecting the Azure Digital Twins service to Azure Storage. Depending on your requirements, you could choose simple storage such as storage accounts. But in most cases, your Azure Digital Twins instance depends on IoT data. Azure Data Lake provides storage for these large amounts of data.

Azure Analytics

Azure Digital Twins is part of the IoT platform. In almost any Azure Digital Twins instance, IoT data is involved such as sensor data. The IoT platform provides several ways of performing analytics.

One of them is called Azure Time Series Insights Gen2. This is an open and scalable end-to-end IoT Analytics service. The service can be used for collecting, processing, storing, and querying IoT data to analyze trends and anomalies. It does not require any lines of code to use this service.

It provides APIs to integrate it into your solution. But it can also be integrated into the workflows defined around your solution.

Together with the Azure Digital Twins service, it can be used to monitor the health, usage, and performance of devices. This allows you to optimize operational efficiency.

Azure Service Bus

Azure Service Bus is cloud messaging as a service (MaaS). It simplifies cloud messaging on an enterprise level by delivering a scalable cloud messaging solution. The service acts as a message broker by using message queues and topics. When you built large IoT solutions including Azure Digital Twins, this service can support the routing of messages from IoT devices to a digital twin. Backend systems can be loosely coupled by using Azure Logic Apps. Azure Functions is used to get messages from the message queue into an Azure Digital Twins instance.

 

Exploring the Azure Digital Twins REST API

As you will have noticed, it is possible to use a large set of different Azure services to connect to Azure Digital Twins as an input, output, management, or compute service. While in some cases, no code is required to make the connection, some services require a more tailormade approach. Azure Functions is such an example. It requires the use of the REST API of the Azure Digital Twins service to access the Digital Twin Graph.

The REST API is divided into two different API models.

REST API Description Operations
Control plane These APIs are used to manage an Azure Digital Twins instance. They provide control over creating, updating, and deleting an entire instance.

Create, update, delete, get, or list Digital Twins instances.

Create, update, delete, get, or list endpoints.

Check for the availability of a name for a Digital Twins instance.

List all available Digital Twins service operations.

Data plane These APIs allow us to manage the different parts of an Azure Digital Twins instance.

Add, update, delete, and list Digital Twins models.

Add, update, delete, and list Digital Twins.

Add, update, delete, and list relationships between Digital Twins.

Send telemetry.

Query a Digital Twins instance.

Add, delete, and list event routes.

Each of these REST APIs is available through different SDKs. This gives you the ability to manage and access the Azure Digital Twins instance from various sources.

The following SDKs are available:

  • .NET SDK – A C# SDK provided through NuGet. This allows you to easily create Azure Functions and other Azure services via Visual Studio by adding the required NuGet packages.
  • Java SDK – A Java SDK to support Maven projects. Maven is an automation tool that is primarily used for building Java projects.
  • JavaScript SDK – A JavaScript SDK available to create web-based solutions that require access to Azure Digital Twins.
  • Python SDK – A Python Package Index (PyPi) SDK that allows you to access the Azure Digital Twins instance by using Python. Python is often used when building intelligent applications with, for example, Azure Machine Learning.

In this book, we will primarily focus on code examples on the .NET SDK.

 

Summary

In this chapter, you have learned and understood the concept of a Digital Twin and viewed a high-level overview of a Digital Twin environment. Based on several use cases and scenarios, we have shown how a Digital Twin can be used. We followed up with Azure Digital Twins, an Azure service that allows you to build a Digital Twin. At a global level, we explained the terminology, tools, architecture, and related Azure services. The final part of this chapter went into the availability of SDKs and APIs and in which languages they are available.

In the next chapters, we will go more into detail about each of the functionalities we have discussed in this chapter. We will guide you, step by step, in designing, creating, and building your own Digital Twin.

About the Author

  • Alexander Meijers

    Alexander Meijers is a professional who inspires, motivates and support others and help them to innovate. His goal is helping organizations achieve more by improving and working smarter. As a Global XR Technology lead and Microsoft Windows MVP for Mixed Reality, working for Avanade, he understands business issues and translate them into logical solutions using technology. He works with XR technologies in combination with cloud services like Mixed Reality services, Azure Digital Twins and Dynamics 365. In the past year, he has designed and implemented a solution wherein data is collected from IoT and Microsoft Dynamics 365 Field service which automatically generates an Azure Digital Twin using Microsoft HoloLens 2 device for visualization.

    Browse publications by this author
Hands-on Azure Digital Twins
Unlock this book and the full library for FREE
Start free trial