Skip to content

Commit 95c1a34

Browse files
authored
Merge pull request #178837 from rido-min/rido-min-dmrupdates
Update IoT PnP Models Repository article
2 parents 60709dc + 9c746b7 commit 95c1a34

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dotnet add package Microsoft.Azure.DigitalTwins.Parser
2424
```
2525

2626
> [!NOTE]
27-
> At the time of writing, the parser version is `3.12.5`.
27+
> At the time of writing, the parser version is `3.12.7`.
2828
2929
## Use the parser to validate a model
3030

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

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Understand concepts of the device models repository | Microsoft Docs
33
description: As a solution developer or an IT professional, learn about the basic concepts of the device models repository.
44
author: rido-min
55
ms.author: rmpablos
6-
ms.date: 11/17/2020
6+
ms.date: 11/12/2021
77
ms.topic: conceptual
88
ms.service: iot-develop
99
services: iot-develop
@@ -13,7 +13,15 @@ services: iot-develop
1313

1414
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/DTDL/v2/dtdlv2.md).
1515

16-
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`.
16+
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).
17+
18+
## Index, expanded and metadata
19+
20+
The DMR conventions include additional artifacts for simplifying consumption of hosted models. These features are _optional_ for custom or private repositories.
21+
22+
- _Index_. All available DTMIs are exposed through an *index* composed by a sequence of json files, for example: [https://devicemodels.azure.com/index.page.2.json](https://devicemodels.azure.com/index.page.2.json)
23+
- _Expanded_. A file with all the dependencies is available for each interface, for example: [https://devicemodels.azure.com/dtmi/com/example/temperaturecontroller-1.expanded.json](https://devicemodels.azure.com/dtmi/com/example/temperaturecontroller-1.expanded.json)
24+
- _Metadata_. This file exposes key attributes of a repository and is refreshed periodically with the latest published models snapshot. It includes features that a repository implements such as whether the model index or expanded model files are available. You can access the DMR metadata at [https://devicemodels.azure.com/metadata.json](https://devicemodels.azure.com/metadata.json)
1725

1826
## Public device models repository
1927

@@ -66,7 +74,6 @@ The `ModelsRepositoryClient` can be configured to query a custom model repositor
6674

6775
- Disabled. Returns the specified interface only, without any dependency.
6876
- Enabled. Returns all the interfaces in the dependency chain
69-
- TryFromExpanded. Use the `.expanded.json` file to retrieve the pre-calculated dependencies
7077

7178
> [!Tip]
7279
> Custom repositories might not expose the `.expanded.json` file, when not available the client will fallback to process each dependency locally.
@@ -77,12 +84,13 @@ The next sample code shows how to initialize the `ModelsRepositoryClient` by usi
7784
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
7885

7986
var client = new ModelsRepositoryClient(
80-
new Uri("https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main"),
81-
new ModelsRepositoryClientOptions(dependencyResolution: ModelDependencyResolution.Enabled));
87+
new Uri("https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main"));
8288

83-
IDictionary<string, string> models = client.GetModels("dtmi:com:example:TemperatureController;1");
89+
ModelResult model = await client.GetModelAsync(
90+
"dtmi:com:example:TemperatureController;1",
91+
dependencyResolution: ModelDependencyResolution.Enabled);
8492

85-
models.Keys.ToList().ForEach(k => Console.WriteLine(k));
93+
model.Content.Keys.ToList().ForEach(k => Console.WriteLine(k));
8694
```
8795

8896
There are more samples available within the source code in the Azure SDK GitHub repository: [Azure.Iot.ModelsRepository/samples](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/modelsrepository/Azure.IoT.ModelsRepository/samples)
@@ -114,11 +122,7 @@ The tools used to validate the models during the PR checks can also be used to a
114122
### Install `dmr-client`
115123

116124
```bash
117-
curl -L https://aka.ms/install-dmr-client-linux | bash
118-
```
119-
120-
```powershell
121-
iwr https://aka.ms/install-dmr-client-windows -UseBasicParsing | iex
125+
dotnet tool install --global Microsoft.IoT.ModelsRepository.CommandLine --version 1.0.0-beta.5
122126
```
123127

124128
### Import a model to the `dtmi/` folder
@@ -169,6 +173,27 @@ Models can be exported from a given repository (local or remote) to a single fil
169173
dmr-client export --dtmi "dtmi:com:example:TemperatureController;1" -o TemperatureController.expanded.json
170174
```
171175

176+
### Create the repository `index`
177+
178+
The DMR can include an *index* with a list of all the DTMIs available at the time of publishing. This file can be split in to multiple files as described in the [DMR Tools Wiki](https://github.com/Azure/iot-plugandplay-models-tools/wiki/Model-Index).
179+
180+
To generate the index in a custom or private DMR, use the index command:
181+
182+
```bash
183+
dmr-client index -r . -o index.json
184+
```
185+
186+
> [!NOTE]
187+
> The public DMR is configured to provide an updated index available at: https://devicemodels.azure.com/index.json
188+
189+
### Create *expanded* files
190+
191+
Expanded files can be generated using the command:
192+
193+
```bash
194+
dmr-client expand -r .
195+
```
196+
172197
## Next steps
173198

174199
The suggested next step is to review the [IoT Plug and Play architecture](concepts-architecture.md).

0 commit comments

Comments
 (0)