DeviceUpdateClient.StartImportUpdate メソッド

定義

新しい更新プログラムのバージョンをインポートします。 これは実行時間の長い操作です。応答ヘッダー値Operation-Location使用して、操作の状態をチェックします。

public virtual Azure.Operation StartImportUpdate (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member StartImportUpdate : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation
override this.StartImportUpdate : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation
Public Overridable Function StartImportUpdate (waitUntil As WaitUntil, content As RequestContent, Optional context As RequestContext = Nothing) As Operation

パラメーター

waitUntil
WaitUntil

Completed メソッドが、サービスで実行時間の長い操作が完了するまで戻るまで待機する必要がある場合。 Started 操作を開始した後に が返される場合は 。 実行時間の長い操作の詳細については、「 Azure.Core Long-Running 操作のサンプル」を参照してください。

content
RequestContent

要求の本文として送信するコンテンツ。 要求本文スキーマの詳細については、以下の「解説」セクションを参照してください。

context
RequestContext

要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。

戻り値

Operationサービスの非同期操作を表す 。

例外

content が null です。

サービスから成功以外の状態コードが返されました。

このサンプルでは、必要なパラメーターと要求コンテンツを使用して StartImportUpdate を呼び出す方法を示します。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceUpdateClient(endpoint, "<instanceId>", credential);

var data = new[] {
    new {
        importManifest = new {
            url = "<url>",
            sizeInBytes = 1234L,
            hashes = new {
                key = "<String>",
            },
        },
        friendlyName = "<friendlyName>",
        files = new[] {
            new {
                filename = "<filename>",
                url = "<url>",
            }
        },
    }
};

var operation = client.StartImportUpdate(WaitUntil.Completed, RequestContent.Create(data));

var response = operation.WaitForCompletionResponse();
Console.WriteLine(response.Status)

注釈

要求ペイロードの JSON スキーマを次に示します。

要求本文:

ImportUpdateInputItemスキーマ:

{
              importManifest: {
                url: string, # Required. Azure Blob location from which the import manifest can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours.
                sizeInBytes: number, # Required. File size in number of bytes.
                hashes: Dictionary<string, string>, # Required. A JSON object containing the hash(es) of the file. At least SHA256 hash is required. This object can be thought of as a set of key-value pairs where the key is the hash algorithm, and the value is the hash of the file calculated using that algorithm.
              }, # Required. Import manifest metadata like source URL, file size/hashes, etc.
              friendlyName: string, # Optional. Friendly update name.
              files: [
                {
                  filename: string, # Required. Update file name as specified inside import manifest.
                  url: string, # Required. Azure Blob location from which the update file can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours.
                }
              ], # Optional. One or more update file properties like filename and source URL.
            }

適用対象