다음을 통해 공유


DeviceManagementClient.StartLogCollectionAsync Method

Definition

Start the device diagnostics log collection on specified devices.

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

Parameters

logCollectionId
String

Log collection identifier.

content
RequestContent

The content to send as the body of the request. Details of the request body schema are in the Remarks section below.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service. Details of the response body schema are in the Remarks section below.

Exceptions

logCollectionId or content is null.

logCollectionId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call StartLogCollectionAsync with required parameters and request content, and how to parse the result.

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 = await client.StartLogCollectionAsync("<logCollectionId>", RequestContent.Create(data));

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

This sample shows how to call StartLogCollectionAsync with all parameters and request content, and how to parse the result.

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 = await client.StartLogCollectionAsync("<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());

Remarks

Below is the JSON schema for the request and response payloads.

Request Body:

Schema for 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.
            }

Response Body:

Schema for 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.
            }

Applies to