SlideShare a Scribd company logo
Requirements and Installation
In this chapter, we will go over all the requirements to get up and running with the Azure Digital Twins
service. We will explain the prerequisites of Azure Digital Twins, as well as how to install and configure
the service. We will also explain how to install and use some of the tools that will help to build Digital
Twins solutions with this service. After this chapter, you will have all the tools available to start building.
In the upcoming chapters, you will learn and understand how to build Digital Twins solutions using Azure
Digital Twins. But before you can start, we need to have the service up and running and some additional
tools to support you.
We will go through the following topics:
 Azure Digital Twins service
 Microsoft Visual Studio
 The Windows Azure CLI with Windows PowerShell
 Node.js
 Azure Digital Twins Explorer
Creating your first Digital
Twin Technical requirements
We will require a computer with Windows 10 and its latest updates installed. It is recommended to have
a 1.8 GHz or faster processor. A quad-core or better is recommended. It is also recommended to have a
minimum of 8 GB of RAM. We will require around 200 GB of available disk space for all installations and
room for projects.
Azure Digital Twins service
The Azure Digital Twins service is a service from Microsoft that provides a means of storing the
definitions, models, and logic around a Digital Twin. Microsoft provides a rich set of APIs and SDKs that
enable all kinds of different ways to interact with, store, retrieve, and update definitions, models, and
logic.
Azure account
An Azure account is required to create and use the Azure Digital Twins service. If you don't have one
available, it is possible to create an Azure account for free today. The Azure account allows you to try
out several services for free over a period of 12 months. After the 12-month period, you will require a
credit card to continue using paid services. Sign up using the following URL:
https://azure.microsoft.com/en-us/free/
After signing up, you will have an Azure Active Directory (AAD) account that allows you to perform
several administrative tasks in the Azure portal. The Azure portal can be found using the following URL:
https://portal.azure.com
Log in with your AAD credentials to get an overview of all your services.
Resource group
In this book, we will be using several different Azure services to create Digital Twin solutions, services
such as Azure Functions, Event Hub, Event Grid, Service Bus, and Logic App. More structure can be
achieved by using Azure resource groups. A resource group is a container that contains related Azure
resources for a specific purpose, in our case, the Digital Twin solutions. It will allow us to easily manage
and control all the resources we will create during the book.
We begin by creating a resource group through the Azure portal. Open a web browser, enter the
URL, https://portal.azure.com, and log in with your AAD credentials.
Perform the following steps:
1. Open the menu on the left by pressing the top-left button with the three lines. This menu is also
called the portal menu.
2. Select Resource groups.
3. Press the + Create button to open the dialog for creating a new resource group:
Figure 2.1 – Start creating a resource group through the Azure portal
In the next dialog, we will create a new user group. Perform the following steps:
1. Select your subscription. The name of the subscription will differ depending on whether you are
using your own subscription, a trial subscription, or another subscription available to you.
Having multiple subscriptions is not uncommon.
2. Enter the name DigitalTwinsBook as the name for your resource group.
3. Select the region of the resource group. You can select any region you want. This region can
differ from the region specified when creating Azure services. At the time of writing this book,
the Azure Digital Twins service is not available in every region. However, that will not be a
problem since the region of the resource group does not have to be the same as the region of
the service.
4. Press the Review + create button to review the information provided before we start creating
the resource group:
Figure 2.2 – Specifying the project details to create a resource group
Pressing the Review + create button will bring us the next dialog, as shown in Figure 2.3. Now, perform
the final step.
5. Press the Create button to create the resource group:
Figure 2.3 – Creating the resource group
In the next step, we will create the Azure Digital Twins service and add it to the resource group we have
just created.
Azure Digital Twins service
Microsoft provides a special Azure service called the Azure Digital Twins service as part of the mixed
reality Azure category. This service is required to build Digital Twin solutions using Microsoft technology.
We will start installing the Azure service. Open the Azure portal if you haven't already done so. Click on
the top-left button to open the portal menu again and select Resource Groups. This will open a list of all
the resource groups created in this Azure portal. Select the DigitalTwinsBook resource group.
You will see an overview of the DigitalTwinsBook resource group. Perform the following step:
1. Press the + Add button to add a new resource to the resource group:
Figure 2.4 – An overview of the DigitalTwinsBook resource group
In the following screenshot, you will see the Azure Marketplace, which contains a large number of Azure
services of Microsoft and third-party vendors. The Azure Digital Twins service is part of the Mixed Reality
and the Internet of Things categories.
There are two options when it comes to finding the service. You can search for it by typing in Azure
Digital Twins in the search field or, as in the example, via the Azure Marketplace categories. Perform the
following steps:
1. Select the category called Mixed Reality.
2. Select the Azure Digital Twins service:
Home DigitalTwinsBook
New
@ Search the Ma rketplace
Azure Marketplace S
e
e all Featured S
e
e all
Get started Spatial
Anchors
Learn more
Recently created
AI + Machine Learning
Analytics
Bloc kchain
Compute
Containers
Databases
Developer Tools
DevOps
Identity
Integration
Internet of
Things
IT & Management
Tools M edia
M igration
Mixed Reality
M onitoring &
Diagnostics
Azure Digital Twins
Learn more
2
Figure 2.5 – Selecting the Azure Digital Twins service via the Mixed Reality category
We will create the Azure Digital Twins service in the next screen. Perform the following steps:
1. Since we are adding from a resource group, the Subscription field is already prefilled with the
subscription used for the resource group. Leave this as it is.
2. Since we are adding from a resource group, the Resource group field is already prefilled with
the resource group. Leave this as it is.
3. Select the Location field for the Azure Digital Twins service. To prevent any performance issues,
it is always best to select the region closest to you.
However, it is not a problem to select a region further away. In my case, the region is West Europe, since
I reside in the Netherlands. More regions will become available over time. Check out the available
regions in the Region dropdown and explore the pricing options at the following URL:
https://azure.microsoft.com/en-us/pricing/details/digital-twins/
4. Enter a name for your resource. Use the name DTBDigitalTwins.
5. Press the Review + create button to review the information provided before we start creating
the resource:
Figure 2.6 – Specifying the project details to create the Azure Digital Twins resource
6. Press the Create button to create the resource:
Figure 2.7 – Creating the Azure Digital Twins resource
It will take some time to create the resource. You will receive a notification when the resource has been
created. From that moment, you can access the resource.
Configuring access control
We will need to configure access control for this resource. Access control is based on RBAC. RBAC stands
for role-based access control. It allows us to assign a specific role to a user, application, service, or
resource. This authorizes users or applications on behalf of a user to execute certain operations against
the resource.
We have the following roles that can be assigned to existing users:
Determine for yourself which account you are going to use while building the examples in this book. In
this example, I will be using my own work account to give it the required rights.
Since we will be creating, deleting, and updating elements from the service, we need to have the owner
role, Azure Digital Twins Data Owner. Select the DTBDigitalTwins resource that has just been created
from the DigitalTwinsBook resource group. Perform the following steps:
1. Select Access control (IAM) from the left-hand menu.
2. Press the + Add button to add a new role assignment.
3. Select the Azure Digital Twins Data Owner role.
4. Search for the name of the account and select it from the search results.
5. Press the Save button to create the new role assignment. The new role assignment for the
selected user is now created:
Figure 2.8 – Assigning an Azure Digital Twin role to an account
IMPORTANT NOTE
You need to have the Azure Digital Twins Data Reader role in order to be able to access the Azure Digital
Twins service when using Azure Digital Twins Explorer.
In this section, we have set up and configured all the necessary Azure Services to run the Azure Digital
Twins service. In the next section, we will begin by installing Microsoft Visual Studio as the tool used
during the book to build the examples.
Microsoft Visual Studio
Several examples require us to program some code. We will be using Microsoft Visual Studio as the
development platform. It is possible to use other applications, such as Visual Studio Code, but they will
not be discussed in this book. There are several different versions of Microsoft Visual Studio available
and you probably already have something installed. But if not, Microsoft has a Community Edition
available. This Community Edition is free for individuals, academic users, and for use in open source
projects. Microsoft Visual Studio Community can be found via the following
URL: https://visualstudio.microsoft.com/free-developer-offers/.
When you open the URL, you will get the option to download the Microsoft Visual Studio Community
Edition:
Figure 2.9 – The download website for the Microsoft Visual Studio Community Edition
The Vs_community_[version].exe file is downloaded into the downloads folder:
Figure 2.10 – The start of the Visual Studio Installer
Execute the file. This will start the Visual Studio Installer. Press the Continue button to continue the
installation:
Figure 2.11 – Selecting the workloads that need to be installed
The installer will install by default most of the required packages to build a variety of applications using
different languages. Separately, it is possible to select one or more workload packages that provide
additional tools to build more specific applications.
In the following step, we need to select the workloads that are required to be installed. Perform the
following steps (Figure 2.11):
1. Since we are primarily using this tool for Azure services, the Azure development workload needs
to be installed. Select this workload.
2. Press the Install button to install Microsoft Visual Studio, including the selected workload
packages.
The installation of Microsoft Visual Studio Community will start. This can take some time, so be
patient:
Figure 2.12 – Installation of Microsoft Visual Studio
You will see the following screen when it's finished:
Figure 2.13 – The installation of Microsoft Visual Studio has finished
As soon as the installer has finished, we can start Visual Studio by pressing the Launch button. This will
open a dialog requesting you to sign in. Enter the credentials you used when creating your Azure
account or use your existing Azure account credentials:
Figure 2.14 – Logging in with your Microsoft or work account credentials
It is possible to log in later when you start Microsoft Visual Studio. The installation and configuration of
Microsoft Visual Studio are now ready to create projects.
In this section, we have installed Visual Studio 2019 along with all its prerequisites. In the next section,
we are going to install the Windows Azure CLI, which is part of Windows PowerShell.
The Windows Azure CLI with Windows PowerShell
We will be using Windows PowerShell to start Azure Digital Twins Explorer.
Windows PowerShell is a set of cmdlets that allows us to manage Azure resources via the PowerShell
command line. Cmdlets are lightweight PowerShell commands written in a compiled .NET language.
The Azure command-line interface, also called the Azure CLI, is a set of commands for managing Azure
resources. It allows us for examples to manage Azure resources using Windows Azure PowerShell.
The Azure CLI will be used to start Azure Digital Twins Explorer.
To install the Azure CLI, we will be using the MSI file, which can be found at the following URL:
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&tabs=azure-
cli.
To check whether the Azure CLI has been installed correctly, we need to start a Windows PowerShell
instance. Perform the following steps:
1. Type in the search field next to the Windows Start button in your Windows 10 environment the
text Windows PowerShell. This will show results containing the Windows PowerShell
application.
2. Start the Windows PowerShell application with administrative rights.
3. Type in the following command: az login.
If the Azure CLI has been installed correctly, this will open a browser window that allows you to log on
with credentials. Log in with your Azure account credentials:
Figure 2.15 – Logged in to Microsoft Azure successfully
When the credentials are correct, you will be redirected to a page explaining that you have been logged
in to Microsoft Azure. A list of available Azure subscriptions is listed through a JSON payload. Now you
can use Azure CLI commands to access Azure resources.
IMPORTANT NOTE
Keep in mind that you will only be able to access and manage Azure resources for which the account you
used to log on is authorized.
We have installed and configured the Windows Azure CLI, which allows us to use Azure CLI commands in
Windows PowerShell. In the next section, we will install and configure Node.js.
Node.js
Node.js is an open source JavaScript runtime environment that allows us to execute JavaScript code
outside a web browser. It is mostly used for creating event-driven servers to create websites and API
services and operates on a single-thread architecture. It allows you to create a local web server with
ease. We will be using Node.js to create the local web server in which Azure Digital Twins Explorer will
run:
Figure 2.16 – The download location of Node.js
We begin by installing Node.js. Perform the following steps:
1. Open a web browser and go to the following URL: https://nodejs.org/en/download. This will
open a download page for Node.js.
2. Select the 32-bit or 64-bit version of the Windows Installer file depending on the Windows 10
operating system that is installed.
This will download the MSI file into the downloads folder. Run the installer. Select the following
installation path: C:Program Filesnodejs.
We need to make sure that the installation location of Node.js is part of the standard PATH variable.
Node.js is required for running the npm command in PowerShell. npm is a package manager for
JavaScript and allows us to compile, build, and run a JavaScript project. And this is exactly what we use
to build and start Azure Digital Twins Explorer.
We have installed and configured Node.js, which is required to get Azure Digital Twins Explorer installed
and running in the next section.
Azure Digital Twins Explorer
While the Azure Digital Twins service stores Digital Twin-related elements, it has no way of visualizing it.
We will need to use the APIs and SDKs to see what is defined therein. For that, Microsoft has released
Azure Digital Twins Explorer. This explorer is one of the Azure samples found at GitHub. It is a JavaScript-
based website that accesses the Azure Digital Twins service via the JavaScript SDK to visualize and
manage an Azure Digital Twins instance.
Download
We will be getting the Azure Digital Twins Explorer source code from GitHub in the following steps. This
requires having an account on GitHub. If you do not have an account, create one accordingly. Open a
web browser and go to the corresponding URL, https://github.com, to create an account.
If you have an account, perform the following steps:
1. Open a web browser and use the following URL: https://github.com/Azure-Samples/digital-
twins-explorer. Make sure you are logged in to GitHub.
2. Select the Code button. This will reveal a drop-down dialog.
3. From the drop-down dialog, select Download ZIP. This will download the complete package
locally to the Downloads folder:
Figure 2.17 – GitHub location of the Azure Digital Twins Explorer source code
4. We need to unpack the downloaded package into a folder. Open Windows File Explorer.
5. Create a Github directory under C:.
6. Unpack the downloaded file into this folder. This will create a digital-twins-explorer-
master folder containing all the files for the Azure Digital Twins Explorer application:
Figure 2.18 – Azure Digital Twins Explorer source code unpacked in the C:Github folder
Now we're ready for installation.
Installation
In this next stage, we will install Azure Digital Twins Explorer. We will be using npm. npm is a package
manager for JavaScript and allows us to compile, build, and run a JavaScript project:
1. Open a Windows PowerShell using administrative rights. Change the current directory to the
source directory of the Azure Digital Twins Explorer project using the following command:
cd c:githubdigital-twins-explorer-mainclientsrc
2. Start the installation by using the following command:
npm install
Here's what the output will look like:
Figure 2.19 – npm is installing all the requisite packages and the packages that these packages depend
on
This command will install all the requisite packages and the packages that these packages depend on.
Compile and run
At this stage, we will compile and run Azure Digital Twins Explorer. It compiles the JavaScript, loads the
packages, and creates a web server. You will need to do this whenever you want to use Azure Digital
Twins Explorer.
Azure Digital Twins requires you to be logged in. Use the following command:
az login
It will open your browser to let you log in:
Figure 2.20 – Logging in to Azure using your Azure account credentials
Use an Azure account that has the Azure Digital Twins Data Owner role. When you log in successfully, it
will list the available subscriptions. In most cases, this will be a single subscription, which is the default
subscription. In some cases, however, like mine, I have several more subscriptions.
The subscription that contains the Azure Digital Twins service must be the default subscription. Azure
Digital Twins Explorer will use the default subscription by default.
Perform the following steps to change the default subscription:
1. Begin with the following command:
az account list --output table
This will list a table containing all available Azure subscriptions, the ID of the Azure subscription, and
whether the Azure subscription is the default subscription:
Figure 2.21 – List of available Azure subscriptions
2. Use the following command to change the default Azure subscription by using the Azure
subscription ID. The following ID is a fake one. It is always best to use the ID since in some cases,
the name of Azure subscriptions can be the same as you see above:
az account set --subscription bb84cef4-9de4-4cab-1232-a72430e321ae
If you are logged in to Azure and have the wrong Azure subscription set to default, Azure Digital Twins
Explorer will generate an error like the following:
Figure 2.22 – Error produced by Azure Digital Twins Explorer
3. Start Azure Digital Twins Explorer by using the following command:
npm run start
4. Azure Digital Twins Explorer will ask you to provide the Azure Digital Twins URL. This URL can be
found by going to the Azure Digital Twins service resource in the Azure portal:
Figure 2.23 – Looking up the hostname of the Azure Digital Twins service
Now, let's perform the following steps to retrieve the hostname of your Azure Digital Twins service:
1. Open the DTBDigitalTwins resource.
2. Select Overview from the left-hand menu.
3. Copy the hostname.
Perform the following steps in Azure Digital Twins Explorer to enter the Azure Digital Twins URL:
1. Enter the URL by combining https:// with the copied hostname.
2. Press the Save button to store the URL:
Figure 2.24 – Configuring the Azure Digital Twins URL in Azure Digital Twins Explorer
You can always change the URL later via the settings icon in the top-right corner.
We have now installed all the necessary tools for building examples and solutions using the Azure Digital
Twins service. In the final section of this chapter, we will be creating our first Digital Twin using these
tools.
Creating your first Digital Twin
This final section will help you to create your first Digital Twin using Azure Digital Twins Explorer. The
source code of Azure Digital Twins Explorer comes with a rich set of example files that we can use to
create the first Digital Twin graph. The example files can be found here: C:Githubdigital-twins-
explorer-masterclientexamples.
The structure of Azure Digital Twins will be explained in depth in the upcoming chapters. For now, we
need to understand that an Azure Digital Twins instance contains one or more Digital Twins. Each Digital
Twin, which represents an entity, is based on a model. A model defines the properties of the Digital Twin
and the relationships to other Digital Twins. A Digital Twin Graph is a visual representation of Digital
Twins and their relationships.
Uploading models
A Digital Twin is always created from a model. Models are defined by JSON files. This means that we
need to upload the models first. Perform the following steps:
1. Select the import model icon at the top of the model view section.
2. Go to the examples folder: C:Githubdigital-twins-explorer-masterclientexamples.
3. Select all JSON files.
4. Press the Open button:
Figure 2.25 – Uploading Digital Twin models into Azure Digital Twin Explorer
This will create the models based on the information from the JSON files. We will go into more detail
regarding the definition of models in the next chapters. The result of the import can be seen here:
Figure 2.26 – Models uploaded to Azure Digital Twins Explorer
In the next step, we need to import the Azure Digital Twins graph. A graph describes the Digital Twins
and their relationships. Each Digital Twin is based on a Digital Twin model:
Figure 2.27 – An Excel file describing the Azure Digital Twin graph
To import this file describing the Azure Digital Twin graph, perform the following steps:
1. Click on the import graph symbol at the top of the graph view.
2. Go to the examples folder: C:Githubdigital-twins-explorer-masterclientexamples.
3. Select the distributionGrid.xlsx file.
4. Press the Open button:
Figure 2.28 – Importing the Digital Twin graph defined by an Excel file
This will start the import of the Azure Digital Twin graph. Initially, you get to see a preview of that graph.
Perform the following steps to import the graph into the Azure Digital Twins instance:
1. Press the Save symbol in the top-right corner in the Import tab.
2. After a short time, a dialog will appear with the number of twins and relationships imported.
Press the Close button to close the dialog:
Figure 2.29 – Importing Azure Digital Twins and relationships
The result shows the Azure Digital Twins graph based on Digital Twins and relationships:
Figure 2.30 – Result of an imported Azure Digital Twins graph
You have created your first Azure Digital Twins graph. In the upcoming chapters, we will go into more
detail regarding how to create your own models and relationships. As part of that, we will also explain
more about how you can edit, the different types of visualization, and running queries using Azure
Digital Twins Explorer.
Summary
During this chapter, you have learned and understood all the prerequisites and requirements for using
the Azure Digital Twins service. You have installed and configured this service. You have also learned
about the necessary tools that allow you to build solutions around Azure Digital Twins. This incorporated
development includes tools such as Microsoft Visual Studio and viewer tools such as Azure Digital Twins
Explorer. You have created your first Digital Twins graph, containing instances of predefined models and
underlying relationships.
In the next chapter, we will go into more detail regarding the definition model of Azure Digital Twins.

More Related Content

PPTX
Azure Digital Twins 2.0
PDF
02microsoftazurefundamentalsworkloads1606403971632.pdf
PPTX
AZ-900T00A-ENU-PowerPoint-02.pptx
PPTX
Microsoft azure overview
PPTX
Getting started with development in azure
PPTX
CL_Architecture of Cassandra Data Processing.pptx
PPTX
Apache Cassandra Lunch #103: Cassandra Cluster Architecture in UML and the Az...
PPTX
Copy of Azure Fundamentals AZ 900THeBest.pptx
Azure Digital Twins 2.0
02microsoftazurefundamentalsworkloads1606403971632.pdf
AZ-900T00A-ENU-PowerPoint-02.pptx
Microsoft azure overview
Getting started with development in azure
CL_Architecture of Cassandra Data Processing.pptx
Apache Cassandra Lunch #103: Cassandra Cluster Architecture in UML and the Az...
Copy of Azure Fundamentals AZ 900THeBest.pptx

Similar to Introduction to Digital twin unit 5 notes (20)

PDF
Metaverse and Digital Twins on Enterprise-Public.pdf
PDF
Microsoft Azure essentials
PDF
Azure Services Platform
PPTX
Fundamentals of Microsoft Azure: AZ-900
PDF
Azure 10 major services
PPTX
Azure from scratch part 3 By Girish Kalamati
PDF
Azure vm introduction
PPTX
Azure digital twins un mundo paralelo
PDF
Microsoft's modern technologies
PPTX
6 Ways to Get More From Your Azure
PPTX
6 Ways to Get More From Your Azure
PPTX
6 Ways to Get More From Your Azure
PPTX
Introduction to Digital twin unit 6 notes
PPTX
London .NET Developers Azure Camp Keynote
PPTX
Perth Azure Usergroup Build 2018 updates
PDF
Adobe nondisclosure-agreement-automation-solution-sb.pd
PPTX
Azure rev002
PPTX
Azure Services Overview
PPTX
671956595-Az-900t00a-Enu-Powerpoint-02.pptx
PPTX
Tokyo azure meetup #8 azure update, august
Metaverse and Digital Twins on Enterprise-Public.pdf
Microsoft Azure essentials
Azure Services Platform
Fundamentals of Microsoft Azure: AZ-900
Azure 10 major services
Azure from scratch part 3 By Girish Kalamati
Azure vm introduction
Azure digital twins un mundo paralelo
Microsoft's modern technologies
6 Ways to Get More From Your Azure
6 Ways to Get More From Your Azure
6 Ways to Get More From Your Azure
Introduction to Digital twin unit 6 notes
London .NET Developers Azure Camp Keynote
Perth Azure Usergroup Build 2018 updates
Adobe nondisclosure-agreement-automation-solution-sb.pd
Azure rev002
Azure Services Overview
671956595-Az-900t00a-Enu-Powerpoint-02.pptx
Tokyo azure meetup #8 azure update, august
Ad

More from Sanjivani college of Engineering (13)

PDF
IT404B Digital Twin (Professional Elective-III) (1).pdf syllabus
PPTX
Introduction to Digital twin unit 4 notes
PPTX
Introduction to Digital twin unit 3 notes
PPTX
Introduction to Digital twin unit 2 notes
PPTX
Introduction to Digital twin unit 1 notes
PDF
2022-2023 Theory of Computation PDF Scanner 04-10-22 10.39.28 CFG .pdf
DOCX
VEIT252 Environmental sustainability desert Eco .docx
DOCX
VEIT252 Environmental sustainability Grassland .docx
PDF
Food-Web-food-chain-ecological-pyramid-ppt-2-25.pdf
PDF
VEIT252 Environmental sustainabilityEVS-Question-Bank.pdf
PDF
VEIT252 Environmental sustainability Unit 2 Pollution .pdf
PPTX
GFCVEIT252 Environmental sustainability-Unit-1-ppt.pptx
PDF
VEIT252 Environmental sustainability Unit 1 Ecosystem
IT404B Digital Twin (Professional Elective-III) (1).pdf syllabus
Introduction to Digital twin unit 4 notes
Introduction to Digital twin unit 3 notes
Introduction to Digital twin unit 2 notes
Introduction to Digital twin unit 1 notes
2022-2023 Theory of Computation PDF Scanner 04-10-22 10.39.28 CFG .pdf
VEIT252 Environmental sustainability desert Eco .docx
VEIT252 Environmental sustainability Grassland .docx
Food-Web-food-chain-ecological-pyramid-ppt-2-25.pdf
VEIT252 Environmental sustainabilityEVS-Question-Bank.pdf
VEIT252 Environmental sustainability Unit 2 Pollution .pdf
GFCVEIT252 Environmental sustainability-Unit-1-ppt.pptx
VEIT252 Environmental sustainability Unit 1 Ecosystem
Ad

Recently uploaded (20)

PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Computing-Curriculum for Schools in Ghana
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Lesson notes of climatology university.
PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Computing-Curriculum for Schools in Ghana
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Lesson notes of climatology university.
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
History, Philosophy and sociology of education (1).pptx
Indian roads congress 037 - 2012 Flexible pavement
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Chinmaya Tiranga quiz Grand Finale.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Supply Chain Operations Speaking Notes -ICLT Program
Digestion and Absorption of Carbohydrates, Proteina and Fats
Orientation - ARALprogram of Deped to the Parents.pptx

Introduction to Digital twin unit 5 notes

  • 1. Requirements and Installation In this chapter, we will go over all the requirements to get up and running with the Azure Digital Twins service. We will explain the prerequisites of Azure Digital Twins, as well as how to install and configure the service. We will also explain how to install and use some of the tools that will help to build Digital Twins solutions with this service. After this chapter, you will have all the tools available to start building. In the upcoming chapters, you will learn and understand how to build Digital Twins solutions using Azure Digital Twins. But before you can start, we need to have the service up and running and some additional tools to support you. We will go through the following topics:  Azure Digital Twins service  Microsoft Visual Studio  The Windows Azure CLI with Windows PowerShell  Node.js  Azure Digital Twins Explorer Creating your first Digital Twin Technical requirements We will require a computer with Windows 10 and its latest updates installed. It is recommended to have a 1.8 GHz or faster processor. A quad-core or better is recommended. It is also recommended to have a minimum of 8 GB of RAM. We will require around 200 GB of available disk space for all installations and room for projects. Azure Digital Twins service The Azure Digital Twins service is a service from Microsoft that provides a means of storing the definitions, models, and logic around a Digital Twin. Microsoft provides a rich set of APIs and SDKs that enable all kinds of different ways to interact with, store, retrieve, and update definitions, models, and logic. Azure account An Azure account is required to create and use the Azure Digital Twins service. If you don't have one available, it is possible to create an Azure account for free today. The Azure account allows you to try out several services for free over a period of 12 months. After the 12-month period, you will require a credit card to continue using paid services. Sign up using the following URL: https://azure.microsoft.com/en-us/free/ After signing up, you will have an Azure Active Directory (AAD) account that allows you to perform several administrative tasks in the Azure portal. The Azure portal can be found using the following URL: https://portal.azure.com
  • 2. Log in with your AAD credentials to get an overview of all your services. Resource group In this book, we will be using several different Azure services to create Digital Twin solutions, services such as Azure Functions, Event Hub, Event Grid, Service Bus, and Logic App. More structure can be achieved by using Azure resource groups. A resource group is a container that contains related Azure resources for a specific purpose, in our case, the Digital Twin solutions. It will allow us to easily manage and control all the resources we will create during the book. We begin by creating a resource group through the Azure portal. Open a web browser, enter the URL, https://portal.azure.com, and log in with your AAD credentials. Perform the following steps: 1. Open the menu on the left by pressing the top-left button with the three lines. This menu is also called the portal menu. 2. Select Resource groups. 3. Press the + Create button to open the dialog for creating a new resource group: Figure 2.1 – Start creating a resource group through the Azure portal In the next dialog, we will create a new user group. Perform the following steps:
  • 3. 1. Select your subscription. The name of the subscription will differ depending on whether you are using your own subscription, a trial subscription, or another subscription available to you. Having multiple subscriptions is not uncommon. 2. Enter the name DigitalTwinsBook as the name for your resource group. 3. Select the region of the resource group. You can select any region you want. This region can differ from the region specified when creating Azure services. At the time of writing this book, the Azure Digital Twins service is not available in every region. However, that will not be a problem since the region of the resource group does not have to be the same as the region of the service. 4. Press the Review + create button to review the information provided before we start creating the resource group: Figure 2.2 – Specifying the project details to create a resource group Pressing the Review + create button will bring us the next dialog, as shown in Figure 2.3. Now, perform the final step. 5. Press the Create button to create the resource group:
  • 4. Figure 2.3 – Creating the resource group In the next step, we will create the Azure Digital Twins service and add it to the resource group we have just created. Azure Digital Twins service Microsoft provides a special Azure service called the Azure Digital Twins service as part of the mixed reality Azure category. This service is required to build Digital Twin solutions using Microsoft technology. We will start installing the Azure service. Open the Azure portal if you haven't already done so. Click on the top-left button to open the portal menu again and select Resource Groups. This will open a list of all the resource groups created in this Azure portal. Select the DigitalTwinsBook resource group. You will see an overview of the DigitalTwinsBook resource group. Perform the following step: 1. Press the + Add button to add a new resource to the resource group:
  • 5. Figure 2.4 – An overview of the DigitalTwinsBook resource group In the following screenshot, you will see the Azure Marketplace, which contains a large number of Azure services of Microsoft and third-party vendors. The Azure Digital Twins service is part of the Mixed Reality and the Internet of Things categories. There are two options when it comes to finding the service. You can search for it by typing in Azure Digital Twins in the search field or, as in the example, via the Azure Marketplace categories. Perform the following steps: 1. Select the category called Mixed Reality. 2. Select the Azure Digital Twins service:
  • 6. Home DigitalTwinsBook New @ Search the Ma rketplace Azure Marketplace S e e all Featured S e e all Get started Spatial Anchors Learn more Recently created AI + Machine Learning Analytics Bloc kchain Compute Containers Databases Developer Tools DevOps Identity Integration Internet of Things IT & Management Tools M edia M igration Mixed Reality M onitoring & Diagnostics Azure Digital Twins Learn more 2
  • 7. Figure 2.5 – Selecting the Azure Digital Twins service via the Mixed Reality category We will create the Azure Digital Twins service in the next screen. Perform the following steps: 1. Since we are adding from a resource group, the Subscription field is already prefilled with the subscription used for the resource group. Leave this as it is. 2. Since we are adding from a resource group, the Resource group field is already prefilled with the resource group. Leave this as it is. 3. Select the Location field for the Azure Digital Twins service. To prevent any performance issues, it is always best to select the region closest to you. However, it is not a problem to select a region further away. In my case, the region is West Europe, since I reside in the Netherlands. More regions will become available over time. Check out the available regions in the Region dropdown and explore the pricing options at the following URL: https://azure.microsoft.com/en-us/pricing/details/digital-twins/ 4. Enter a name for your resource. Use the name DTBDigitalTwins. 5. Press the Review + create button to review the information provided before we start creating the resource:
  • 8. Figure 2.6 – Specifying the project details to create the Azure Digital Twins resource 6. Press the Create button to create the resource:
  • 9. Figure 2.7 – Creating the Azure Digital Twins resource It will take some time to create the resource. You will receive a notification when the resource has been created. From that moment, you can access the resource. Configuring access control We will need to configure access control for this resource. Access control is based on RBAC. RBAC stands for role-based access control. It allows us to assign a specific role to a user, application, service, or resource. This authorizes users or applications on behalf of a user to execute certain operations against the resource. We have the following roles that can be assigned to existing users:
  • 10. Determine for yourself which account you are going to use while building the examples in this book. In this example, I will be using my own work account to give it the required rights. Since we will be creating, deleting, and updating elements from the service, we need to have the owner role, Azure Digital Twins Data Owner. Select the DTBDigitalTwins resource that has just been created from the DigitalTwinsBook resource group. Perform the following steps: 1. Select Access control (IAM) from the left-hand menu. 2. Press the + Add button to add a new role assignment. 3. Select the Azure Digital Twins Data Owner role. 4. Search for the name of the account and select it from the search results. 5. Press the Save button to create the new role assignment. The new role assignment for the selected user is now created: Figure 2.8 – Assigning an Azure Digital Twin role to an account IMPORTANT NOTE You need to have the Azure Digital Twins Data Reader role in order to be able to access the Azure Digital Twins service when using Azure Digital Twins Explorer. In this section, we have set up and configured all the necessary Azure Services to run the Azure Digital Twins service. In the next section, we will begin by installing Microsoft Visual Studio as the tool used during the book to build the examples.
  • 11. Microsoft Visual Studio Several examples require us to program some code. We will be using Microsoft Visual Studio as the development platform. It is possible to use other applications, such as Visual Studio Code, but they will not be discussed in this book. There are several different versions of Microsoft Visual Studio available and you probably already have something installed. But if not, Microsoft has a Community Edition available. This Community Edition is free for individuals, academic users, and for use in open source projects. Microsoft Visual Studio Community can be found via the following URL: https://visualstudio.microsoft.com/free-developer-offers/. When you open the URL, you will get the option to download the Microsoft Visual Studio Community Edition: Figure 2.9 – The download website for the Microsoft Visual Studio Community Edition The Vs_community_[version].exe file is downloaded into the downloads folder:
  • 12. Figure 2.10 – The start of the Visual Studio Installer Execute the file. This will start the Visual Studio Installer. Press the Continue button to continue the installation: Figure 2.11 – Selecting the workloads that need to be installed The installer will install by default most of the required packages to build a variety of applications using different languages. Separately, it is possible to select one or more workload packages that provide additional tools to build more specific applications.
  • 13. In the following step, we need to select the workloads that are required to be installed. Perform the following steps (Figure 2.11): 1. Since we are primarily using this tool for Azure services, the Azure development workload needs to be installed. Select this workload. 2. Press the Install button to install Microsoft Visual Studio, including the selected workload packages. The installation of Microsoft Visual Studio Community will start. This can take some time, so be patient: Figure 2.12 – Installation of Microsoft Visual Studio You will see the following screen when it's finished:
  • 14. Figure 2.13 – The installation of Microsoft Visual Studio has finished As soon as the installer has finished, we can start Visual Studio by pressing the Launch button. This will open a dialog requesting you to sign in. Enter the credentials you used when creating your Azure account or use your existing Azure account credentials:
  • 15. Figure 2.14 – Logging in with your Microsoft or work account credentials It is possible to log in later when you start Microsoft Visual Studio. The installation and configuration of Microsoft Visual Studio are now ready to create projects. In this section, we have installed Visual Studio 2019 along with all its prerequisites. In the next section, we are going to install the Windows Azure CLI, which is part of Windows PowerShell. The Windows Azure CLI with Windows PowerShell We will be using Windows PowerShell to start Azure Digital Twins Explorer. Windows PowerShell is a set of cmdlets that allows us to manage Azure resources via the PowerShell command line. Cmdlets are lightweight PowerShell commands written in a compiled .NET language.
  • 16. The Azure command-line interface, also called the Azure CLI, is a set of commands for managing Azure resources. It allows us for examples to manage Azure resources using Windows Azure PowerShell. The Azure CLI will be used to start Azure Digital Twins Explorer. To install the Azure CLI, we will be using the MSI file, which can be found at the following URL: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&tabs=azure- cli. To check whether the Azure CLI has been installed correctly, we need to start a Windows PowerShell instance. Perform the following steps: 1. Type in the search field next to the Windows Start button in your Windows 10 environment the text Windows PowerShell. This will show results containing the Windows PowerShell application. 2. Start the Windows PowerShell application with administrative rights. 3. Type in the following command: az login. If the Azure CLI has been installed correctly, this will open a browser window that allows you to log on with credentials. Log in with your Azure account credentials: Figure 2.15 – Logged in to Microsoft Azure successfully When the credentials are correct, you will be redirected to a page explaining that you have been logged in to Microsoft Azure. A list of available Azure subscriptions is listed through a JSON payload. Now you can use Azure CLI commands to access Azure resources. IMPORTANT NOTE Keep in mind that you will only be able to access and manage Azure resources for which the account you used to log on is authorized. We have installed and configured the Windows Azure CLI, which allows us to use Azure CLI commands in Windows PowerShell. In the next section, we will install and configure Node.js. Node.js Node.js is an open source JavaScript runtime environment that allows us to execute JavaScript code outside a web browser. It is mostly used for creating event-driven servers to create websites and API services and operates on a single-thread architecture. It allows you to create a local web server with
  • 17. ease. We will be using Node.js to create the local web server in which Azure Digital Twins Explorer will run: Figure 2.16 – The download location of Node.js We begin by installing Node.js. Perform the following steps: 1. Open a web browser and go to the following URL: https://nodejs.org/en/download. This will open a download page for Node.js. 2. Select the 32-bit or 64-bit version of the Windows Installer file depending on the Windows 10 operating system that is installed. This will download the MSI file into the downloads folder. Run the installer. Select the following installation path: C:Program Filesnodejs. We need to make sure that the installation location of Node.js is part of the standard PATH variable. Node.js is required for running the npm command in PowerShell. npm is a package manager for JavaScript and allows us to compile, build, and run a JavaScript project. And this is exactly what we use to build and start Azure Digital Twins Explorer. We have installed and configured Node.js, which is required to get Azure Digital Twins Explorer installed and running in the next section.
  • 18. Azure Digital Twins Explorer While the Azure Digital Twins service stores Digital Twin-related elements, it has no way of visualizing it. We will need to use the APIs and SDKs to see what is defined therein. For that, Microsoft has released Azure Digital Twins Explorer. This explorer is one of the Azure samples found at GitHub. It is a JavaScript- based website that accesses the Azure Digital Twins service via the JavaScript SDK to visualize and manage an Azure Digital Twins instance. Download We will be getting the Azure Digital Twins Explorer source code from GitHub in the following steps. This requires having an account on GitHub. If you do not have an account, create one accordingly. Open a web browser and go to the corresponding URL, https://github.com, to create an account. If you have an account, perform the following steps: 1. Open a web browser and use the following URL: https://github.com/Azure-Samples/digital- twins-explorer. Make sure you are logged in to GitHub. 2. Select the Code button. This will reveal a drop-down dialog. 3. From the drop-down dialog, select Download ZIP. This will download the complete package locally to the Downloads folder: Figure 2.17 – GitHub location of the Azure Digital Twins Explorer source code 4. We need to unpack the downloaded package into a folder. Open Windows File Explorer. 5. Create a Github directory under C:.
  • 19. 6. Unpack the downloaded file into this folder. This will create a digital-twins-explorer- master folder containing all the files for the Azure Digital Twins Explorer application: Figure 2.18 – Azure Digital Twins Explorer source code unpacked in the C:Github folder Now we're ready for installation. Installation In this next stage, we will install Azure Digital Twins Explorer. We will be using npm. npm is a package manager for JavaScript and allows us to compile, build, and run a JavaScript project: 1. Open a Windows PowerShell using administrative rights. Change the current directory to the source directory of the Azure Digital Twins Explorer project using the following command: cd c:githubdigital-twins-explorer-mainclientsrc 2. Start the installation by using the following command: npm install Here's what the output will look like:
  • 20. Figure 2.19 – npm is installing all the requisite packages and the packages that these packages depend on This command will install all the requisite packages and the packages that these packages depend on. Compile and run At this stage, we will compile and run Azure Digital Twins Explorer. It compiles the JavaScript, loads the packages, and creates a web server. You will need to do this whenever you want to use Azure Digital Twins Explorer. Azure Digital Twins requires you to be logged in. Use the following command: az login It will open your browser to let you log in:
  • 21. Figure 2.20 – Logging in to Azure using your Azure account credentials Use an Azure account that has the Azure Digital Twins Data Owner role. When you log in successfully, it will list the available subscriptions. In most cases, this will be a single subscription, which is the default subscription. In some cases, however, like mine, I have several more subscriptions. The subscription that contains the Azure Digital Twins service must be the default subscription. Azure Digital Twins Explorer will use the default subscription by default. Perform the following steps to change the default subscription: 1. Begin with the following command: az account list --output table This will list a table containing all available Azure subscriptions, the ID of the Azure subscription, and whether the Azure subscription is the default subscription:
  • 22. Figure 2.21 – List of available Azure subscriptions 2. Use the following command to change the default Azure subscription by using the Azure subscription ID. The following ID is a fake one. It is always best to use the ID since in some cases, the name of Azure subscriptions can be the same as you see above: az account set --subscription bb84cef4-9de4-4cab-1232-a72430e321ae If you are logged in to Azure and have the wrong Azure subscription set to default, Azure Digital Twins Explorer will generate an error like the following: Figure 2.22 – Error produced by Azure Digital Twins Explorer 3. Start Azure Digital Twins Explorer by using the following command: npm run start 4. Azure Digital Twins Explorer will ask you to provide the Azure Digital Twins URL. This URL can be found by going to the Azure Digital Twins service resource in the Azure portal:
  • 23. Figure 2.23 – Looking up the hostname of the Azure Digital Twins service Now, let's perform the following steps to retrieve the hostname of your Azure Digital Twins service: 1. Open the DTBDigitalTwins resource. 2. Select Overview from the left-hand menu. 3. Copy the hostname. Perform the following steps in Azure Digital Twins Explorer to enter the Azure Digital Twins URL: 1. Enter the URL by combining https:// with the copied hostname. 2. Press the Save button to store the URL:
  • 24. Figure 2.24 – Configuring the Azure Digital Twins URL in Azure Digital Twins Explorer You can always change the URL later via the settings icon in the top-right corner. We have now installed all the necessary tools for building examples and solutions using the Azure Digital Twins service. In the final section of this chapter, we will be creating our first Digital Twin using these tools. Creating your first Digital Twin This final section will help you to create your first Digital Twin using Azure Digital Twins Explorer. The source code of Azure Digital Twins Explorer comes with a rich set of example files that we can use to create the first Digital Twin graph. The example files can be found here: C:Githubdigital-twins- explorer-masterclientexamples. The structure of Azure Digital Twins will be explained in depth in the upcoming chapters. For now, we need to understand that an Azure Digital Twins instance contains one or more Digital Twins. Each Digital Twin, which represents an entity, is based on a model. A model defines the properties of the Digital Twin and the relationships to other Digital Twins. A Digital Twin Graph is a visual representation of Digital Twins and their relationships. Uploading models A Digital Twin is always created from a model. Models are defined by JSON files. This means that we need to upload the models first. Perform the following steps: 1. Select the import model icon at the top of the model view section. 2. Go to the examples folder: C:Githubdigital-twins-explorer-masterclientexamples. 3. Select all JSON files. 4. Press the Open button:
  • 25. Figure 2.25 – Uploading Digital Twin models into Azure Digital Twin Explorer This will create the models based on the information from the JSON files. We will go into more detail regarding the definition of models in the next chapters. The result of the import can be seen here:
  • 26. Figure 2.26 – Models uploaded to Azure Digital Twins Explorer In the next step, we need to import the Azure Digital Twins graph. A graph describes the Digital Twins and their relationships. Each Digital Twin is based on a Digital Twin model:
  • 27. Figure 2.27 – An Excel file describing the Azure Digital Twin graph To import this file describing the Azure Digital Twin graph, perform the following steps: 1. Click on the import graph symbol at the top of the graph view. 2. Go to the examples folder: C:Githubdigital-twins-explorer-masterclientexamples. 3. Select the distributionGrid.xlsx file. 4. Press the Open button:
  • 28. Figure 2.28 – Importing the Digital Twin graph defined by an Excel file This will start the import of the Azure Digital Twin graph. Initially, you get to see a preview of that graph. Perform the following steps to import the graph into the Azure Digital Twins instance: 1. Press the Save symbol in the top-right corner in the Import tab. 2. After a short time, a dialog will appear with the number of twins and relationships imported. Press the Close button to close the dialog:
  • 29. Figure 2.29 – Importing Azure Digital Twins and relationships The result shows the Azure Digital Twins graph based on Digital Twins and relationships: Figure 2.30 – Result of an imported Azure Digital Twins graph
  • 30. You have created your first Azure Digital Twins graph. In the upcoming chapters, we will go into more detail regarding how to create your own models and relationships. As part of that, we will also explain more about how you can edit, the different types of visualization, and running queries using Azure Digital Twins Explorer. Summary During this chapter, you have learned and understood all the prerequisites and requirements for using the Azure Digital Twins service. You have installed and configured this service. You have also learned about the necessary tools that allow you to build solutions around Azure Digital Twins. This incorporated development includes tools such as Microsoft Visual Studio and viewer tools such as Azure Digital Twins Explorer. You have created your first Digital Twins graph, containing instances of predefined models and underlying relationships. In the next chapter, we will go into more detail regarding the definition model of Azure Digital Twins.