|
1 | 1 | ---
|
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. |
4 | 4 | author: andrewbrownmsft
|
5 | 5 | ms.author: andbrown
|
6 |
| -ms.date: 08/23/2022 |
| 6 | +ms.date: 01/24/2023 |
7 | 7 | ms.topic: how-to
|
8 | 8 | ms.service: iot-hub-device-update
|
9 | 9 | ---
|
10 | 10 |
|
11 |
| -# Use the related files feature in Device Update for IoT Hub |
| 11 | +# Use the related files feature to reference multiple update files |
12 | 12 |
|
13 | 13 | Use the related files feature when you need to express relationships between different update files in a single update.
|
14 | 14 |
|
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. |
18 | 16 |
|
19 | 17 | 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.
|
20 | 18 |
|
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. |
22 | 36 |
|
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). |
24 | 45 |
|
25 | 46 | ```json
|
26 | 47 | {
|
@@ -76,20 +97,31 @@ Below is an example of an import manifest that uses the related files feature to
|
76 | 97 | }
|
77 | 98 | ```
|
78 | 99 |
|
79 |
| -## How to use related files |
| 100 | +## Example init command using related files |
80 | 101 |
|
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. |
85 | 103 |
|
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: |
87 | 105 |
|
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 | +``` |
89 | 109 |
|
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 | +``` |
91 | 123 |
|
92 | 124 | ## Next steps
|
93 | 125 |
|
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