Skip to content

Commit 1abbd3d

Browse files
Merge pull request #232615 from dominicbetts/developer-dtdl-updates
IoT Developer: DTDL updates
2 parents 9c17b81 + 31a1221 commit 1abbd3d

12 files changed

+46
-88
lines changed

articles/iot-develop/concepts-architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following diagram shows the key elements of an IoT Plug and Play solution:
2727

2828
## Model repository
2929

30-
The [model repository](./concepts-model-repository.md) is a store for model and interface definitions. You define models and interfaces using the [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md).
30+
The [model repository](./concepts-model-repository.md) is a store for model and interface definitions. You define models and interfaces using the [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md).
3131

3232
The web UI lets you manage the models and interfaces.
3333

articles/iot-develop/concepts-convention.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IoT Plug and Play devices should follow a set of conventions when they exchange
1515

1616
A device can include [modules](../iot-hub/iot-hub-devguide-module-twins.md), or be implemented in an [IoT Edge module](../iot-edge/about-iot-edge.md) hosted by the IoT Edge runtime.
1717

18-
You describe the telemetry, properties, and commands that an IoT Plug and Play device implements with a [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md) _model_. There are two types of model referred to in this article:
18+
You describe the telemetry, properties, and commands that an IoT Plug and Play device implements with a [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md) _model_. There are two types of model referred to in this article:
1919

2020
- **No component** - A model with no components. The model declares telemetry, properties, and commands as top-level elements in the contents section of the main interface. In the Azure IoT explorer tool, this model appears as a single _default component_.
2121
- **Multiple components** - A model composed of two or more interfaces. A main interface, which appears as the _default component_, with telemetry, properties, and commands. One or more interfaces declared as components with more telemetry, properties, and commands.
@@ -48,7 +48,7 @@ A read-only property is set by the device and reported to the back-end applicati
4848

4949
### Sample no component read-only property
5050

51-
A device or module can send any valid JSON that follows the DTDL V2 rules.
51+
A device or module can send any valid JSON that follows the DTDL rules.
5252

5353
DTDL that defines a property on an interface:
5454

@@ -282,7 +282,7 @@ The device responds with an acknowledgment that looks like the following example
282282

283283
When a device receives multiple desired properties in a single payload, it can send the reported property responses across multiple payloads or combine the responses into a single payload.
284284

285-
A device or module can send any valid JSON that follows the DTDL V2 rules.
285+
A device or module can send any valid JSON that follows the DTDL rules.
286286

287287
DTDL:
288288

@@ -452,7 +452,7 @@ On a device or module, multiple component interfaces use command names with the
452452

453453
Now that you've learned about IoT Plug and Play conventions, here are some other resources:
454454

455-
- [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md)
455+
- [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md)
456456
- [C device SDK](https://github.com/Azure/azure-iot-sdk-c/)
457457
- [IoT REST API](/rest/api/iothub/device)
458458
- [IoT Plug and Play modeling guide](concepts-modeling-guide.md)

articles/iot-develop/concepts-developer-guide-device.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This guide describes the basic steps required to create a device, module, or IoT
3939
To build an IoT Plug and Play device, module, or IoT Edge module, follow these steps:
4040

4141
1. Ensure your device is using either the MQTT or MQTT over WebSockets protocol to connect to Azure IoT Hub.
42-
1. Create a [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md) model to describe your device. To learn more, see [Understand components in IoT Plug and Play models](concepts-modeling-guide.md).
42+
1. Create a [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md) model to describe your device. To learn more, see [Understand components in IoT Plug and Play models](concepts-modeling-guide.md).
4343
1. Update your device or module to announce the `model-id` as part of the device connection.
4444
1. Implement telemetry, properties, and commands that follow the [IoT Plug and Play conventions](concepts-convention.md)
4545

@@ -85,7 +85,7 @@ Once your device or module implementation is ready, use the [Azure IoT explorer]
8585

8686
Now that you've learned about IoT Plug and Play device development, here are some other resources:
8787

88-
- [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md)
88+
- [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md)
8989
- [C device SDK](https://github.com/Azure/azure-iot-sdk-c/)
9090
- [IoT REST API](/rest/api/iothub/device)
9191
- [Understand components in IoT Plug and Play models](concepts-modeling-guide.md)

articles/iot-develop/concepts-developer-guide-service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The service SDKs let you access device information from a solution component suc
6969

7070
Now that you've learned about device modeling, here are some more resources:
7171

72-
- [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md)
72+
- [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md)
7373
- [C device SDK](https://github.com/Azure/azure-iot-sdk-c/)
7474
- [IoT REST API](/rest/api/iothub/device)
7575
- [IoT Plug and Play modeling guide](concepts-modeling-guide.md)

articles/iot-develop/concepts-digital-twin.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ title: Understand IoT Plug and Play digital twins
33
description: Understand how IoT Plug and Play uses digital twins
44
author: dominicbetts
55
ms.author: dobett
6-
ms.date: 11/17/2022
6+
ms.date: 04/25/2023
77
ms.topic: conceptual
88
ms.service: iot-develop
99
services: iot-develop
1010
---
1111

1212
# Understand IoT Plug and Play digital twins
1313

14-
An IoT Plug and Play device implements a model described by the [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md) schema. A model describes the set of components, properties, commands, and telemetry messages that a particular device can have.
15-
16-
IoT Plug and Play uses DTDL version 2. For more information about this version, see the [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md) specification on GitHub.
14+
An IoT Plug and Play device implements a model described by the [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md) schema. A model describes the set of components, properties, commands, and telemetry messages that a particular device can have.
1715

1816
> [!NOTE]
1917
> DTDL isn't exclusive to IoT Plug and Play. Other IoT services, such as [Azure Digital Twins](../digital-twins/overview.md), use it to represent entire environments such as buildings and energy networks.

articles/iot-develop/concepts-model-parser.md

Lines changed: 22 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Understand the Azure Digital Twins model parser | Microsoft Docs
33
description: As a developer, learn how to use the DTDL parser to validate models.
44
author: rido-min
55
ms.author: rmpablos
6-
ms.date: 11/17/2022
6+
ms.date: 04/25/2023
77
ms.topic: conceptual
88
ms.custom: mvc
99
ms.service: iot-develop
@@ -13,75 +13,35 @@ services: iot-develop
1313

1414
# Understand the digital twins model parser
1515

16-
The Digital Twins Definition Language (DTDL) is described in the [DTDL Specification V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md). Users can use the _Digital Twins Model Parser_ NuGet package to validate and query a DTDL model. The DTDL model may be defined in multiple files.
16+
The Digital Twins Definition Language (DTDL) is described in the [DTDL Specification](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md). Users can use the _Digital Twins Model Parser_ NuGet package to validate and query a DTDL model. The DTDL model may be defined in multiple files.
1717

1818
## Install the DTDL model parser
1919

20-
The parser is available in NuGet.org with the ID: [Microsoft.Azure.DigitalTwins.Parser](https://www.nuget.org/packages/Microsoft.Azure.DigitalTwins.Parser). To install the parser, use any compatible NuGet package manager such as the one in Visual Studio or in the `dotnet` CLI.
20+
The parser is available in NuGet.org with the ID: [DTDLParser](https://www.nuget.org/packages/DTDLParser). To install the parser, use any compatible NuGet package manager such as the one in Visual Studio or in the `dotnet` CLI.
2121

2222
```bash
23-
dotnet add package Microsoft.Azure.DigitalTwins.Parser
23+
dotnet add package DTDLParser
2424
```
2525

2626
> [!NOTE]
27-
> At the time of writing, the parser version is `3.12.7`.
28-
29-
## Use the parser to validate a model
30-
31-
A model can be composed of one or more interfaces described in JSON files. You can use the parser to load all the files in a given folder and then validate all the files as a whole, including any references between the files:
32-
33-
1. Create an `IEnumerable<string>` with a list of all model contents:
34-
35-
```csharp
36-
using System.IO;
37-
38-
string folder = @"c:\myModels\";
39-
string filespec = "*.json";
40-
41-
List<string> modelJson = new List<string>();
42-
foreach (string filename in Directory.GetFiles(folder, filespec))
43-
{
44-
using StreamReader modelReader = new StreamReader(filename);
45-
modelJson.Add(modelReader.ReadToEnd());
46-
}
47-
```
48-
49-
1. Instantiate the `ModelParser` and call `ParseAsync`:
50-
51-
```csharp
52-
using Microsoft.Azure.DigitalTwins.Parser;
53-
54-
ModelParser modelParser = new ModelParser();
55-
IReadOnlyDictionary<Dtmi, DTEntityInfo> parseResult = await modelParser.ParseAsync(modelJson);
56-
```
57-
58-
1. Check for validation errors. If the parser finds any errors, it throws an `ParsingException` with a list of errors:
59-
60-
```csharp
61-
try
62-
{
63-
IReadOnlyDictionary<Dtmi, DTEntityInfo> parseResult = await modelParser.ParseAsync(modelJson);
64-
}
65-
catch (ParsingException pex)
66-
{
67-
Console.WriteLine(pex.Message);
68-
foreach (var err in pex.Errors)
69-
{
70-
Console.WriteLine(err.PrimaryID);
71-
Console.WriteLine(err.Message);
72-
}
73-
}
74-
```
75-
76-
1. Inspect the `Model`. If the validation succeeds, you can use the model parser API to inspect the model. The following code snippet shows how to iterate over all the models parsed and display the existing properties:
77-
78-
```csharp
79-
foreach (var item in parseResult)
80-
{
81-
Console.WriteLine($"\t{item.Key}");
82-
Console.WriteLine($"\t{item.Value.DisplayName?.Values.FirstOrDefault()}");
83-
}
84-
```
27+
> At the time of writing, the parser version is `1.0.52`.
28+
29+
## Use the parser to validate and inspect a model
30+
31+
The DTDLParser is a library that you can use to:
32+
33+
- Determine whether one or more models are valid according to the language v2 or v3 specifications.
34+
- Identify specific modeling errors.
35+
- Inspect model contents.
36+
37+
A model can be composed of one or more interfaces described in JSON files. You can use the parser to load all the files that define a model and then validate all the files as a whole, including any references between the files.
38+
39+
The [DTDLParser for .NET](https://github.com/digitaltwinconsortium/DTDLParser) repository includes the following samples that illustrate the use of the parser:
40+
41+
- [DTDLParserResolveSample](https://github.com/digitaltwinconsortium/DTDLParser/blob/main/samples/DTDLParserResolveSample) shows how to parse an interface with external references, resolve the dependencies using the `Azure.IoT.ModelsRepository` client.
42+
- [DTDLParserJSInteropSample](https://github.com/digitaltwinconsortium/DTDLParser/blob/main/samples/DTDLParserJSInteropSample) shows how to use the DTDL Parser from JavaScript running in the browser, using .NET JSInterop.
43+
44+
The DTDLParser for .NET repository also includes a [collection of tutorials](https://github.com/digitaltwinconsortium/DTDLParser/blob/main/tutorials/README.md) that show you how to use the parser to validate and inspect models.
8545

8646
## Next steps
8747

articles/iot-develop/concepts-model-repository.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services: iot-develop
1111

1212
# Device models repository
1313

14-
The device models repository (DMR) enables device builders to manage and share IoT Plug and Play device models. The device models are JSON LD documents defined using the [Digital Twins Modeling Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md).
14+
The device models repository (DMR) enables device builders to manage and share IoT Plug and Play device models. The device models are JSON LD documents defined using the [Digital Twins Modeling Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md).
1515

1616
The DMR defines a pattern to store DTDL interfaces in a folder structure based on the device twin model identifier (DTMI). You can locate an interface in the DMR by converting the DTMI to a relative path. For example, the `dtmi:com:example:Thermostat;1` DTMI translates to `/dtmi/com/example/thermostat-1.json` and can be obtained from the public base URL `devicemodels.azure.com` at the URL [https://devicemodels.azure.com/dtmi/com/example/thermostat-1.json](https://devicemodels.azure.com/dtmi/com/example/thermostat-1.json).
1717

articles/iot-develop/concepts-modeling-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ At the core of IoT Plug and Play, is a device _model_ that describes a device's
2222

2323
To learn more about how IoT Plug and Play uses device models, see [IoT Plug and Play device developer guide](concepts-developer-guide-device.md) and [IoT Plug and Play service developer guide](concepts-developer-guide-service.md).
2424

25-
To define a model, you use the Digital Twins Definition Language (DTDL) V2. DTDL uses a JSON variant called [JSON-LD](https://json-ld.org/). The following snippet shows the model for a thermostat device that:
25+
To define a model, you use the Digital Twins Definition Language (DTDL). DTDL uses a JSON variant called [JSON-LD](https://json-ld.org/). The following snippet shows the model for a thermostat device that:
2626

2727
- Has a unique model ID: `dtmi:com:example:Thermostat;1`.
2828
- Sends temperature telemetry.
@@ -126,7 +126,7 @@ The thermostat model has a single interface. Later examples in this article show
126126

127127
This article describes how to design and author your own models and covers topics such as data types, model structure, and tools.
128128

129-
To learn more, see the [Digital Twins Definition Language V2](https://github.com/Azure/opendigitaltwins-dtdl) specification.
129+
To learn more, see the [Digital Twins Definition Language](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md) specification.
130130

131131
## Model structure
132132

@@ -642,7 +642,7 @@ There's a DTDL authoring extension for VS Code.
642642

643643
To install the DTDL extension for VS Code, go to [DTDL editor for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-dtdl). You can also search for **DTDL** in the **Extensions** view in VS Code.
644644

645-
When you've installed the extension, use it to help you author DTDL model files in VS code:
645+
When you've installed the extension, use it to help you author DTDL model files in VS Code:
646646

647647
- The extension provides syntax validation in DTDL model files, highlighting errors as shown on the following screenshot:
648648

@@ -690,5 +690,5 @@ The following list summarizes some key constraints and limits on models:
690690

691691
Now that you've learned about device modeling, here are some more resources:
692692

693-
- [Digital Twins Definition Language V2 (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl)
693+
- [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md)
694694
- [Model repositories](./concepts-model-repository.md)

articles/iot-develop/howto-convert-to-pnp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ In summary, the sample implements the following capabilities:
170170
171171
## Design a model
172172
173-
Every IoT Plug and Play device has a model that describes the features and capabilities of the device. The model uses the [Digital Twin Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md) to describe the device capabilities.
173+
Every IoT Plug and Play device has a model that describes the features and capabilities of the device. The model uses the [Digital Twin Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md) to describe the device capabilities.
174174
175175
For a simple model that maps the existing capabilities of your device, use the *Telemetry*, *Property*, and *Command* DTDL elements.
176176

articles/iot-develop/howto-manage-digital-twin.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IoT Plug and Play supports **Get digital twin** and **Update digital twin** oper
1515

1616
## Update a digital twin
1717

18-
An IoT Plug and Play device implements a model described by [Digital Twins Definition Language (DTDL) V2](https://github.com/Azure/opendigitaltwins-dtdl). Solution developers can use the **Update Digital Twin API** to update the state of component and the properties of the digital twin.
18+
An IoT Plug and Play device implements a model described by [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md). Solution developers can use the **Update Digital Twin API** to update the state of component and the properties of the digital twin.
1919

2020
The IoT Plug and Play device used as an example in this article implements the [Temperature Controller model](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/samples/TemperatureController.json) with [Thermostat](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/samples/Thermostat.json) components.
2121

@@ -150,25 +150,25 @@ The following JSON Patch sample shows how to add, replace, or remove a property
150150

151151
**Name**
152152

153-
The name of a component or property must be valid DTDL V2 name.
153+
The name of a component or property must be valid DTDL name.
154154

155155
Allowed characters are a-z, A-Z, 0-9 (not as the first character), and underscore (not as the first or last character).
156156

157157
A name can be 1-64 characters long.
158158

159159
**Property value**
160160

161-
The value must be a valid [DTDL V2 Property](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md#property).
161+
The value must be a valid [DTDL Property](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md#property).
162162

163-
All primitive types are supported. Within complex types, enums, maps, and objects are supported. To learn more, see [DTDL V2 Schemas](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/DTDL.v2.md#schema).
163+
All primitive types are supported. Within complex types, enums, maps, and objects are supported. To learn more, see [DTDL Schemas](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md#schema).
164164

165165
Properties don't support array or any complex schema with an array.
166166

167167
A maximum depth of a five levels is supported for a complex object.
168168

169-
All field names within complex object should be valid DTDL V2 names.
169+
All field names within complex object should be valid DTDL names.
170170

171-
All map keys should be valid DTDL V2 names.
171+
All map keys should be valid DTDL names.
172172

173173
## Troubleshoot update digital twin API errors
174174

0 commit comments

Comments
 (0)