Skip to content

Commit 5eb0858

Browse files
authored
Merge pull request #224804 from kgremban/jan23-durelatedfiles
Review related-files
2 parents d65ecbc + 5ea0987 commit 5eb0858

File tree

4 files changed

+68
-33
lines changed

4 files changed

+68
-33
lines changed

articles/iot-hub-device-update/create-update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ For handler properties, you may need to escape certain characters in your JSON.
8383

8484
The `init` command supports advanced scenarios, including the [related files feature](related-files.md) that allows you to define the relationship between different update files. For more examples and a complete list of optional parameters, see [az iot du init v5](/cli/azure/iot/du/update/init#az-iot-du-update-init-v5).
8585

86-
Once you've created your import manifest and saved it as a JSON file, if you're ready to [import your update](import-update.md).
86+
Once you've created your import manifest and saved it as a JSON file, you're ready to [import your update](import-update.md).
8787

8888
## Create an advanced Device Update import manifest for a proxy update
8989

articles/iot-hub-device-update/delta-updates.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,44 +149,43 @@ sudo ./DiffGenTool
149149

150150
## Import the generated delta update
151151

152-
### Generate import manifest
153-
154152
The basic process of importing an update to the Device Update service is unchanged for delta updates, so if you haven't already, be sure to review this page: [How to prepare an update to be imported into Azure Device Update for IoT Hub](create-update.md)
155153

154+
### Generate import manifest
155+
156156
The first step to import an update into the Device Update service is always to create an import manifest if you don't already have one. For more information about import manifests, see [Importing updates into Device Update](import-concepts.md#import-manifest). For delta updates, your import manifest will need to reference two files:
157+
157158
- The _recompressed_ target SWU image created when you ran the DiffGen tool.
158159
- The delta file created when you ran the DiffGen tool.
159160

160-
The delta update feature uses a new capability called [Related Files](related-files.md), which requires an import manifest that is version 5 or later.
161+
The delta update feature uses a capability called [related files](related-files.md), which requires an import manifest that is version 5 or later.
161162

162-
To create an import manifest for your delta update using the Related Files feature, you'll need to add [relatedFiles](import-schema.md#relatedfiles-object) and [downloadHandler](import-schema.md#downloadhandler-object) elements to your import manifest.
163+
To create an import manifest for your delta update using the related files feature, you'll need to add [relatedFiles](import-schema.md#relatedfiles-object) and [downloadHandler](import-schema.md#downloadhandler-object) objects to your import manifest.
163164

164-
The `relatedFiles` element is used to specify information about the delta update file, including the file name, file size and sha256 hash (examples available at the link above). Importantly, you also need to specify two properties which are unique to the delta update feature:
165+
Use the `relatedFiles` object to specify information about the delta update file, including the file name, file size and sha256 hash. Importantly, you also need to specify two properties which are unique to the delta update feature:
165166

166167
```json
167168
"properties": {
168169
"microsoft.sourceFileHashAlgorithm": "sha256",
169170
"microsoft.sourceFileHash": "[insert the source SWU image file hash]"
170171
}
171172
```
173+
172174
Both of the properties above are specific to your _source SWU image file_ that you used as an input to the DiffGen tool when creating your delta update. The information about the source SWU image is needed in your import manifest even though you will not actually be importing the source image. The delta components on the device use this metadata about the source image to locate the image on the device once the delta has been downloaded.
173175

174-
The `downloadHandler` element is used to specify how the Device Update agent will orchestrate the delta update, using the Related Files feature. Unless you are customizing your own version of the Device Update agent for delta functionality, you should only use this downloadHandler:
176+
Use the `downloadHandler` object to specify how the Device Update agent will orchestrate the delta update, using the related files feature. Unless you are customizing your own version of the Device Update agent for delta functionality, you should only use this downloadHandler:
175177

176178
```json
177179
"downloadHandler": {
178180
"id": "microsoft/delta:1"
179181
}
180182
```
181-
You can use the Azure Command Line Interface (CLI) to generate an import manifest for your delta update. If you haven't used the Azure CLI to create an import manifest before, refer to [these instructions](create-update.md#create-a-basic-device-update-import-manifest).
183+
184+
You can use the Azure Command Line Interface (CLI) to generate an import manifest for your delta update. If you haven't used the Azure CLI to create an import manifest before, see [Create a basic import manifest](create-update.md#create-a-basic-device-update-import-manifest).
182185

183186
```azurecli
184-
az iot du update init v5
185-
--update-provider <replace with your Provider> --update-name <replace with your update Name> --update-version <replace with your update Version>
186-
--compat manufacturer=<replace with the value your device will report> model=<replace with the value your device will report>
187-
--step handler=microsoft/swupdate:2 properties=<replace with any desired handler properties (JSON-formatted), such as '{"installedCriteria": "1.0"}'>
188-
--file path=<replace with path(s) to your update file(s), including the full file name> downloadHandler=microsoft/delta:1
189-
--related-file path=<replace with path(s) to your delta file(s), including the full file name> properties='{"microsoft.sourceFileHashAlgorithm": "sha256", "microsoft.sourceFileHash": "<replace with the source SWU image file hash>"}'
187+
az iot du update init v5
188+
--update-provider <replace with your Provider> --update-name <replace with your update Name> --update-version <replace with your update Version> --compat manufacturer=<replace with the value your device will report> model=<replace with the value your device will report> --step handler=microsoft/swupdate:2 properties=<replace with any desired handler properties (JSON-formatted), such as '{"installedCriteria": "1.0"}'> --file path=<replace with path(s) to your update file(s), including the full file name> downloadHandler=microsoft/delta:1 --related-file path=<replace with path(s) to your delta file(s), including the full file name> properties='{"microsoft.sourceFileHashAlgorithm": "sha256", "microsoft.sourceFileHash": "<replace with the source SWU image file hash>"}'
190189
```
191190

192191
Save your generated import manifest JSON to a file with the extension `.importmanifest.json`

articles/iot-hub-device-update/import-schema.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ For example:
221221
}
222222
}
223223
```
224+
224225
## relatedFiles object
225226

226227
Collection of related files to one or more of your primary payload files.
@@ -251,6 +252,9 @@ For example:
251252
}
252253
],
253254
```
255+
256+
For more information, see [Use the related files feature to reference multiple update files](related-files.md).
257+
254258
## downloadHandler object
255259

256260
Specifies how to process any related files.

articles/iot-hub-device-update/related-files.md

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
---
2-
title: Related files for Device Update for Azure IoT Hub | Microsoft Docs
3-
description: Understand the Device Update for IoT Hub related files feature.
2+
title: Related files for Device Update for Azure IoT Hub
3+
description: Create import manifests that reference multiple update files using the Device Update for IoT Hub related files feature.
44
author: andrewbrownmsft
55
ms.author: andbrown
6-
ms.date: 08/23/2022
6+
ms.date: 01/24/2023
77
ms.topic: how-to
88
ms.service: iot-hub-device-update
99
---
1010

11-
# Use the related files feature in Device Update for IoT Hub
11+
# Use the related files feature to reference multiple update files
1212

1313
Use the related files feature when you need to express relationships between different update files in a single update.
1414

15-
## What is the related files feature?
16-
17-
When importing an update to Device Update for IoT Hub, an import manifest containing metadata about the update payload is required. The file-level metadata in the import manifest can be a flat list of update payload files in the simplest case. However, for more advanced scenarios, you can instead use the related files feature, which provides a way for files to have a relationship specified between them.
15+
When importing an update to Device Update for IoT Hub, an import manifest containing metadata about the update payload is required. The file-level metadata in the import manifest can be a flat list of update payload files in the simplest case. However, for more advanced scenarios, the related files feature provides a way for you to specify relationships between multiple update files.
1816

1917
When creating an import manifest using the related files feature, you can add a collection of _related_ files to one or more of your _primary_ payload files. An example of this concept is the Device Update [delta update](delta-updates.md) feature, which uses related files to specify a delta update that is associated with a full image file. In the delta scenario, the related files feature allows the full image and delta update to both be imported as a single update action, and then either one can be deployed to a device. However, the related files feature isn't limited to delta updates, since it's designed to be extensible by our customers depending on their own unique scenarios.
2018

21-
### Example import manifest using related files
19+
## How to define related files
20+
21+
The related files feature is available for import manifests that are version 5 or later.
22+
23+
When you add related files to an import manifest, include the following information:
24+
25+
* File details
26+
27+
Define the related files by providing the filename, size, and hash.
28+
29+
* A download handler
30+
31+
Specify how to process these related files to produce the target file. You specify the processing approach by including a `downloadHandler` property in your import manifest. Including `downloadHandler` is required if you specify a non-empty collection of `relatedFiles` in a `file` element. You can specify a `downloadHandler` using a simple `id` property. The Download handler `id` has a limit of 64 ASCII characters.
32+
33+
* Related files properties
34+
35+
You can provide extra metadata for the update handler on your device to know how to interpret and properly use the files that you've specified as related files. This metadata is added as part of a `properties` property bag to the `file` and `relatedFile` objects.
2236

23-
Below is an example of an import manifest that uses the related files feature to import a delta update. In this example, you can see that in the `files` section, there's a full image specified (`full-image-file-name`) with a `properties` item. The `properties` item in turn has an associated `relatedFiles` item below it. Within the `relatedFiles` section, you can see another `properties` section for the delta update file (`delta-from-v1-file-name`), and also a `downloadHandler` item with the appropriate `id` listed (`microsoft/delta:1`).
37+
For more information about the import schema for related files, see [relatedFiles object](import-schema.md#relatedfiles-object).
38+
39+
## Example import manifest using related files
40+
41+
The following sample import manifest demonstrates how the related files feature is used to import a delta update. In this example, you can see that in the `files` section, there's a full image specified (`full-image-file-name`) with a `properties` item. The `properties` item in turn has an associated `relatedFiles` item below it. Within the `relatedFiles` section, you can see another `properties` section for the delta update file (`delta-from-v1-file-name`), and also a `downloadHandler` item with the appropriate `id` listed (`microsoft/delta:1`).
42+
43+
>[!NOTE]
44+
>This example uses delta updates to demonstrate how to reference related files. If you want to use delta updates as a feature, learn more in the [delta update documentation](delta-updates.md).
2445
2546
```json
2647
{
@@ -76,20 +97,31 @@ Below is an example of an import manifest that uses the related files feature to
7697
}
7798
```
7899

79-
## How to use related files
100+
## Example init command using related files
80101

81-
>[!NOTE]
82-
>The documentation on this page uses delta updates as an example of how to use related files. If you want to use delta updates as a _feature_, follow the [delta update documentation](delta-updates.md).
83-
84-
### Related files properties
102+
The [az iot du init v5](/cli/azure/iot/du/update/init#az-iot-du-update-init-v5) command for creating an import manifest supports an optional `--related-file` parameter.
85103

86-
In certain scenarios, you may want to provide extra metadata for the update handler on your device to know how to interpret and properly use the files that you've specified as related files. This metadata is added as part of a `properties` property bag to the `file` and `relatedFile` objects.
104+
The `--related-file` parameter takes a `path` and `properties` key:
87105

88-
### Specify a download handler
106+
```azurecli
107+
--related-file path=<replace with path(s) to your delta file(s), including the full file name> properties='{"microsoft.sourceFileHashAlgorithm": "sha256", "microsoft.sourceFileHash": "<replace with the source SWU image file hash>"}'
108+
```
89109

90-
When you use the related files feature, you need to specify how to process these related files to produce the target file. You specify the processing approach by including a `downloadHandler` property in your import manifest. Including `downloadHandler` is required if you specify a non-empty collection of `relatedFiles` in a `file` element. You can specify a `downloadHandler` using a simple `id` property. The Download handler `id` has a limit of 64 ASCII characters.
110+
For example:
111+
112+
```azurecli
113+
az iot du update init v5 \
114+
--update-provider Microsoft --update-name myBundled --update-version 2.0 \
115+
--compat manufacturer=Contoso model=SpaceStation \
116+
--step handler=microsoft/script:1 properties='{"arguments": "--pre"}' description="Pre-install script" \
117+
--file path=/my/update/scripts/preinstall.sh downloadHandler=microsoft/delta:1 \
118+
--related-file path=/my/update/scripts/related_preinstall.json properties='{"microsoft.sourceFileHashAlgorithm": "sha256"}' \
119+
--step updateId.provider=Microsoft updateId.name=SwUpdate updateId.version=1.1 \
120+
--step handler=microsoft/script:1 properties='{"arguments": "--post"}' description="Post-install script" \
121+
--file path=/my/update/scripts/postinstall.sh
122+
```
91123

92124
## Next steps
93125

94-
- Learn about [import manifest schema](import-schema.md)
95-
- Learn about [delta updates](delta-updates.md)
126+
* Learn about [import manifest schema](import-schema.md)
127+
* Learn about [delta updates](delta-updates.md)

0 commit comments

Comments
 (0)