次の方法で共有


DeviceManagementClient.StartLogCollection メソッド

定義

指定したデバイスでデバイス 診断ログ収集を開始します。

public virtual Azure.Response StartLogCollection(string logCollectionId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member StartLogCollection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.StartLogCollection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function StartLogCollection (logCollectionId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response

パラメーター

logCollectionId
String

ログ 収集識別子。

content
RequestContent

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

context
RequestContext

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

戻り値

サービスから返された応答。 応答本文スキーマの詳細については、以下の「解説」セクションを参照してください。

例外

logCollectionId または content が null です。

logCollectionId は空の文字列であり、空でないと想定されていました。

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

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

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

var data = new {
    deviceList = new[] {
        new {
            deviceId = "<deviceId>",
        }
    },
};

Response response = client.StartLogCollection("<logCollectionId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("deviceId").ToString());

このサンプルでは、すべてのパラメーターと要求コンテンツを使用して StartLogCollection を呼び出す方法と、結果を解析する方法を示します。

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

var data = new {
    operationId = "<operationId>",
    deviceList = new[] {
        new {
            deviceId = "<deviceId>",
            moduleId = "<moduleId>",
        }
    },
    description = "<description>",
};

Response response = client.StartLogCollection("<logCollectionId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("operationId").ToString());
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("deviceId").ToString());
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("moduleId").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
Console.WriteLine(result.GetProperty("status").ToString());

注釈

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

要求本文:

LogCollectionスキーマ:

{
              operationId: string, # Optional. The log collection id.
              deviceList: [
                {
                  deviceId: string, # Required. Device Id
                  moduleId: string, # Optional. Module Id
                }
              ], # Required. Array of Device Update agent ids
              description: string, # Optional. Description of the diagnostics operation.
              createdDateTime: string, # Optional. The timestamp when the operation was created.
              lastActionDateTime: string, # Optional. A timestamp for when the current state was entered.
              status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Optional. Operation status.
            }

応答本文:

LogCollectionスキーマ:

{
              operationId: string, # Optional. The log collection id.
              deviceList: [
                {
                  deviceId: string, # Required. Device Id
                  moduleId: string, # Optional. Module Id
                }
              ], # Required. Array of Device Update agent ids
              description: string, # Optional. Description of the diagnostics operation.
              createdDateTime: string, # Optional. The timestamp when the operation was created.
              lastActionDateTime: string, # Optional. A timestamp for when the current state was entered.
              status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Optional. Operation status.
            }

適用対象