Share via


Device Update for IoT Hub にインポートする更新を準備する

新しい更新を取得して、Device Update for IoT Hub にインポートするために更新を準備する方法について説明します。

前提条件

  • Device Update for IoT Hub が有効になっている IoT Hub にアクセスできること。

  • Azure CLI 環境:

    1. az login コマンドを使用して、Azure CLI にサインインします。
    2. az version を実行し、インストールされているバージョンおよび依存ライブラリを検索します。 最新バージョンにアップグレードするには、az upgrade を実行します。
    3. 初回使用時に確認を求められたら、Azure CLI 拡張機能をインストールします。 この記事のコマンドでは、azure-iot 拡張機能を使います。 az extension update --name azure-iot を実行して、最新バージョンの拡張機能を使用していることを確認してください。

ヒント

この記事の Azure CLI コマンドでは、行の継続に円記号 \ を使用して、コマンド引数を読みやすくします。 この構文は、Bash 環境で機能します。 PowerShell でこれらのコマンドを実行している場合は、各円記号をバックティック (`) に置き換えるか、完全に削除します。

デバイスの更新プログラムを入手する

Device Update を設定し、デバイスをプロビジョニングしたので、これらのデバイスに配置する更新ファイルが必要になります。

  • OEM (相手先ブランド供給) またはソリューション インテグレーターからデバイスを購入した場合、その組織によって更新ファイルが提供される可能性が高いため、更新プログラムを作成する必要はありません。 OEM またはソリューション インテグレーターに問い合わせて、更新プログラムの入手方法を確認してください。

  • 自分の組織が使用するデバイス用のソフトウェアを作成している場合は、その同じグループが、そのソフトウェア用の更新プログラムを作成します。

Device Update for IoT Hub を使用して配置される更新プログラムを作成する場合は、シナリオに応じて、イメージベースまたはパッケージベースの方法のいずれかで開始します。

基本的な Device Update のインポート マニフェストを作成する

更新ファイルを作成したら、インポート マニフェストを作成して更新プログラムを記述します。 基本的なインポートの概念をまだ理解していない場合は、理解しておきましょう。 テキスト エディターでインポート マニフェスト JSON を手動で作成することもできますが、Azure コマンド ライン インターフェイス (CLI) を使用すると、このプロセスが非常に簡単になります。これは、以下の例で使用されています。

ヒント

イメージベースパッケージベース、またはプロキシ更新のチュートリアルをまだ行っていない場合は、試してみてください。 また、これらのチュートリアルで、インポート マニフェスト ファイルのサンプルを参考として見るだけでもかまいません。

az iot du init v5 コマンドは、次の引数を受け取ります。

  • --update-provider--update-name、および --update-version: これら 3 つのパラメーターは、更新ごとに一意の識別子である updateId オブジェクトを定義します。
  • --compat: 互換性オブジェクトは、この更新プログラムと互換性のあるデバイスのプロパティを記述する名前と値のペアのセットです。
    • 互換性プロパティのまったく同じセットを、複数のプロバイダーと名前の組み合わせで使用することはできません。
  • --step: デバイス上の更新ハンドラー (microsoft/script:1microsoft/swupdate:1microsoft/apt:1 など) と、この更新プログラムに関連付けられているプロパティ
  • --file: 更新ファイルまたは複数の更新ファイルへのパス。

これらのパラメーターの詳細については、スキーマと API 情報のインポートに関するページを参照してください。

az iot du update init v5 \
    --update-provider <replace with your Provider> \
    --update-name <replace with your update Name> \
    --update-version <replace with your update Version> \
    --compat <replace with the property name>=<replace with the value your device will report> <replace with the property name>=<replace with the value your device will report> \
    --step handler=<replace with your chosen handler> properties=<replace with any handler properties (JSON-formatted)> \
    --file path=<replace with path(s) to your update file(s), including the full file name> 

次に例を示します。

az iot du update init v5 \
    --update-provider Microsoft \
    --update-name AptUpdate \
    --update-version 1.0.0 \
    --compat manufacturer=Contoso model=Vacuum \
    --step handler=microsoft/script:1 properties='{"installedCriteria": "1.0"}' \
    --file path=/my/apt/manifest/file

ハンドラー プロパティでは、JSON の特定の文字をエスケープする必要がある場合があります。 たとえば、PowerShell で Azure CLI を実行している場合は、'\' を使用して二重引用符をエスケープします。

init コマンドは、さまざまな更新ファイル間のリレーションシップを定義できる関連ファイル機能など、高度なシナリオをサポートします。 その他の例と省略可能なパラメーターの完全な一覧については、「az iot du init v5」を参照してください。

インポート マニフェストを作成し、これを JSON ファイルとして保存したら、更新プログラムをインポートする準備ができています。 インポートに Azure portal UI を使用する場合は、インポート マニフェストの名前を "<manifestname>.importmanifest.json" の形式にします。

プロキシ更新用の高度な Device Update インポート マニフェストを作成する

プロキシ更新など、更新が複雑な場合は、複数のインポート マニフェストの作成が必要になることがあります。 前のセクションと同じ Azure CLI アプローチを使用して、複雑な更新のために "親" インポート マニフェストといくつかの "子" インポート マニフェストの両方を作成できます。 サンプル パラメーターの値を独自の値に置き換えた後、次の Azure CLI コマンドを実行します。 使用できる値の詳細については、スキーマと API の情報のインポートに関する記事を参照してください。 次の例では、デバイスに展開する 3 つの更新プログラム (1 つの親更新プログラムと 2 つの子更新プログラム) があります。

az iot du update init v5 \
    --update-provider <replace with child_1 update Provider> \
    --update-name <replace with child_1 update Name> \
    --update-version <replace with child_1 update Version> \
    --compat manufacturer=<replace with the value your device will report> model=<replace with the value your device will report> \
    --step handler=<replace with your chosen handler> \
    --file path=<replace with path(s) to your update file(s), including the full file name> \
az iot du update init v5 \
    --update-provider <replace with child_2 update Provider> \
    --update-name <replace with child_2 update Name> \
    --update-version <replace with child_2 update Version> \
    --compat manufacturer=<replace with the value your device will report> model=<replace with the value your device will report> \
    --step handler=<replace with your chosen handler> \
    --file path=<replace with path(s) to your update file(s), including the full file name> \
az iot du update init v5 \
    --update-provider <replace with the parent update Provider> \
    --update-name <replace with the parent update Name> \
    --update-version <replace with the parent update Version> \
    --compat manufacturer=<replace with the value your device will report> model=<replace with the value your device will report> \
    --step handler=<replace with your chosen handler> properties=<replace with any desired handler properties (JSON-formatted)> \
    --file path=<replace with path(s) to your update file(s), including the full file name> \
    --step updateId.provider=<replace with child_1 update provider> updateId.name=<replace with child_1 update name> updateId.version=<replace with child_1 update version> \
    --step updateId.provider=<replace with child_2 update provider> updateId.name=<replace with child_2 update name> updateId.version=<replace with child_2 update version> \

次のステップ