Skip to content

Commit 7591786

Browse files
authored
Merge pull request #268915 from dominicbetts/model-repo-remove
IoT PnP: Remove publish to model repository references
2 parents 010dda3 + 2840e7b commit 7591786

8 files changed

+84
-231
lines changed

articles/iot-central/core/concepts-device-templates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ For a device to interact with IoT Central, it must be assigned to a device templ
3939
IoT Central can automatically assign a device to a device template when the device connects. A device should send a [model ID](../../iot/iot-glossary.md?toc=/azure/iot-central/toc.json&bc=/azure/iot-central/breadcrumb/toc.json#model-id) when it connects. IoT Central uses the model ID to identify the device template for that specific device model. The discovery process works as follows:
4040

4141
1. If the device template is already published in the IoT Central application, the device is assigned to the device template.
42-
1. If the device template isn't already published in the IoT Central application, IoT Central looks for the device model in the [public model repository](https://github.com/Azure/iot-plugandplay-models). If IoT Central finds the model, it uses it to generate a basic device template.
42+
1. If the device template isn't already published in the IoT Central application, IoT Central looks for the device model in the public device model repository. If IoT Central finds the model, it uses it to generate a basic device template.
4343
1. If IoT Central doesn't find the model in the public model repository, the device is marked as **Unassigned**. An operator can:
4444

4545
- Create a device template for the device and then migrate the unassigned device to the new device template.

articles/iot-develop/.openpublishing.redirection.iot-develop.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@
9292
},
9393
{
9494
"source_path_from_root": "/articles/iot-pnp/howto-manage-models.md",
95-
"redirect_url": "/azure/iot-develop/concepts-model-discovery",
95+
"redirect_url": "/azure/iot/concepts-model-discovery",
9696
"redirect_document_id": false
9797
},
9898
{
9999
"source_path_from_root": "/articles/iot-pnp/howto-use-iot-pnp-cli.md",
100-
"redirect_url": "/azure/iot-develop/concepts-model-repository",
100+
"redirect_url": "/azure/iot/concepts-model-discovery",
101101
"redirect_document_id": false
102102
},
103103
{
@@ -342,18 +342,18 @@
342342
},
343343
{
344344
"source_path_from_root": "/articles/iot-pnp/concepts-model-discovery.md",
345-
"redirect_url": "/azure/iot-develop/concepts-model-discovery",
346-
"redirect_document_id": true
345+
"redirect_url": "/azure/iot/concepts-model-discovery",
346+
"redirect_document_id": false
347347
},
348348
{
349349
"source_path_from_root": "/articles/iot-pnp/concepts-model-parser.md",
350-
"redirect_url": "/azure/iot-develop/concepts-model-parser",
351-
"redirect_document_id": true
350+
"redirect_url": "/azure/iot/concepts-model-parser",
351+
"redirect_document_id": false
352352
},
353353
{
354354
"source_path_from_root": "/articles/iot-pnp/concepts-model-repository.md",
355-
"redirect_url": "/azure/iot-develop/concepts-model-repository",
356-
"redirect_document_id": true
355+
"redirect_url": "/azure/iot/concepts-model-discovery",
356+
"redirect_document_id": false
357357
},
358358
{
359359
"source_path_from_root": "/articles/iot-pnp/connect-web.md",
@@ -493,12 +493,12 @@
493493
{
494494
"source_path_from_root": "/articles/iot-develop/concepts-model-discovery.md",
495495
"redirect_url": "/azure/iot/concepts-model-discovery",
496-
"redirect_document_id": true
496+
"redirect_document_id": false
497497
},
498498
{
499499
"source_path_from_root": "/articles/iot-develop/concepts-model-repository.md",
500-
"redirect_url": "/azure/iot/concepts-model-repository",
501-
"redirect_document_id": true
500+
"redirect_url": "/azure/iot/concepts-model-discovery",
501+
"redirect_document_id": false
502502
},
503503
{
504504
"source_path_from_root": "/articles/iot-develop/concepts-model-parser.md",
@@ -569,6 +569,11 @@
569569
"source_path_from_root": "/articles/iot-develop/quickstart-send-telemetry-central.md",
570570
"redirect_url": "/azure/iot-central/core/tutorial-connect-device",
571571
"redirect_document_id": false
572+
},
573+
{
574+
"source_path_from_root": "/articles/iot/concepts-model-repository.md",
575+
"redirect_url": "/azure/iot/concepts-model-discovery",
576+
"redirect_document_id": true
572577
}
573578
]
574579
}

articles/iot/TOC.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ items:
9595
href: concepts-modeling-guide.md
9696
- name: Use models in a solution
9797
href: concepts-model-discovery.md
98-
- name: Model repository
99-
href: concepts-model-repository.md
10098
- name: Model parser
10199
href: concepts-model-parser.md
102100

articles/iot/concepts-architecture.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ The following diagram shows the key elements of an IoT Plug and Play solution:
2525

2626
## Model repository
2727

28-
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).
28+
The [model repository](./concepts-model-discovery.md) is a store for curated model and interface definitions. Models and interfaces are defined using the [Digital Twins Definition Language (DTDL)](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/README.md).
2929

30-
The web UI lets you manage the models and interfaces.
31-
32-
The model repository has built-in role-based access controls that let you manage access to interface definitions.
30+
The web UI lets you search for and retrieve the models and interfaces.
3331

3432
## Devices
3533

@@ -89,6 +87,5 @@ The backend solution can use the information from the interface definitions to:
8987

9088
Now that you have an overview of the architecture of an IoT Plug and Play solution, the next steps are to learn more about:
9189

92-
- [The model repository](./concepts-model-repository.md)
9390
- [Digital twin model integration](./concepts-model-discovery.md)
9491
- [Developing for IoT Plug and Play](./concepts-developer-guide-device.md)

articles/iot/concepts-model-discovery.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Use IoT Plug and Play models in a solution | Microsoft Docs
33
description: As a solution builder, learn about how you can use IoT Plug and Play models in your IoT solution.
44
author: dominicbetts
55
ms.author: dobett
6-
ms.date: 1/23/2024
6+
ms.date: 03/13/2024
77
ms.topic: conceptual
88
ms.service: iot
99
---
@@ -111,16 +111,69 @@ A solution can get the model definition by using one of the following options:
111111

112112
### Model repository
113113

114-
Solutions can use the [model repository](concepts-model-repository.md) to retrieve models. Either the device builders or the solution builders must upload their models to the repository beforehand so the solution can retrieve them.
114+
Solutions can retrieve DTDL models from the device model repository (DMR). The DMR is a public repository, hosted by Microsoft, that contains a collection of curated DTDL models. The public device models stored in the DMR are available for everyone to consume and integrate in their applications from the public endpoint [https://devicemodels.azure.com](https://devicemodels.azure.com).
115115

116116
After you identify the model ID for a new device connection, follow these steps:
117117

118-
1. Retrieve the model definition using the model ID from the model repository. For more information, see [Device model repository](concepts-model-repository.md).
118+
1. Retrieve the model definition using the model ID from the model repository. For more information, see [Resolve models](#resolve-models).
119119

120120
1. Using the model definition of the connected device, you can enumerate the capabilities of the device.
121121

122122
1. Using the enumerated capabilities of the device, you can enable users to [interact with the device](tutorial-service.md).
123123

124+
### Resolve models
125+
126+
The DMR conventions include other artifacts for simplifying consumption of hosted models. These features are *optional* for custom or private repositories.
127+
128+
- *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)
129+
- *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)
130+
- *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)
131+
132+
To programmatically access the public DTDL models in the DMR, you can use the `ModelsRepositoryClient` available in the NuGet package [Azure.IoT.ModelsRepository](https://www.nuget.org/packages/Azure.IoT.ModelsRepository). This client is configured by default to query the public DMR available at [devicemodels.azure.com](https://devicemodels.azure.com/) and can be configured to any custom repository.
133+
134+
The client accepts a `DTMI` as input and returns a dictionary with all required interfaces:
135+
136+
```cs
137+
using Azure.IoT.ModelsRepository;
138+
139+
var client = new ModelsRepositoryClient();
140+
ModelResult models = client.GetModel("dtmi:com:example:TemperatureController;1");
141+
models.Content.Keys.ToList().ForEach(k => Console.WriteLine(k));
142+
```
143+
144+
The expected output displays the `DTMI` of the three interfaces found in the dependency chain:
145+
146+
```txt
147+
dtmi:com:example:TemperatureController;1
148+
dtmi:com:example:Thermostat;1
149+
dtmi:azure:DeviceManagement:DeviceInformation;1
150+
```
151+
152+
The `ModelsRepositoryClient` can be configured to query a custom DMR -available through http(s)- and to specify the dependency resolution by using the `ModelDependencyResolution` flag:
153+
154+
- Disabled. Returns the specified interface only, without any dependency.
155+
- Enabled. Returns all the interfaces in the dependency chain
156+
157+
> [!TIP]
158+
> Custom repositories might not expose the `.expanded.json` file. When this file isn't available, the client will fallback to process each dependency locally.
159+
160+
The following sample code shows how to initialize the `ModelsRepositoryClient` by using a custom repository base URL, in this case using the `raw` URLs from the GitHub API without using the `expanded` form since it's not available in the `raw` endpoint. The `AzureEventSourceListener` is initialized to inspect the HTTP request performed by the client:
161+
162+
```cs
163+
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
164+
165+
var client = new ModelsRepositoryClient(
166+
new Uri("https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main"));
167+
168+
ModelResult model = await client.GetModelAsync(
169+
"dtmi:com:example:TemperatureController;1",
170+
dependencyResolution: ModelDependencyResolution.Enabled);
171+
172+
model.Content.Keys.ToList().ForEach(k => Console.WriteLine(k));
173+
```
174+
175+
There are more samples available 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).
176+
124177
### Custom store
125178

126179
Solutions can store these model definitions in a local file system, in a public file store, or use a custom implementation.

0 commit comments

Comments
 (0)