次の方法で共有


DeviceManagementClient.GetLogCollectionAsync(String, RequestContext) メソッド

定義

デバイス診断ログ収集を取得します。

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

パラメーター

logCollectionId
String

ログ コレクション識別子。

context
RequestContext

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

戻り値

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

例外

logCollectionId が null です。

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

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

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

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

Response response = await client.GetLogCollectionAsync("<logCollectionId>");

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

適用対象