次の方法で共有


LogsQueryClient.QueryBatchAsync(LogsBatchQuery, CancellationToken) メソッド

定義

バッチ クエリを送信します。 バッチ クエリを LogsBatchQuery 作成するには、 を使用します。

string workspaceId = "<workspace_id>";

var client = new LogsQueryClient(new DefaultAzureCredential());

// Query TOP 10 resource groups by event count
// And total event count
var batch = new LogsBatchQuery();

string countQueryId = batch.AddWorkspaceQuery(
    workspaceId,
    "AzureActivity | count",
    new QueryTimeRange(TimeSpan.FromDays(1)));
string topQueryId = batch.AddWorkspaceQuery(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count",
    new QueryTimeRange(TimeSpan.FromDays(1)));

Response<LogsBatchQueryResultCollection> response = await client.QueryBatchAsync(batch);

var count = response.Value.GetResult<int>(countQueryId).Single();
var topEntries = response.Value.GetResult<MyLogEntryModel>(topQueryId);

Console.WriteLine($"AzureActivity has total {count} events");
foreach (var logEntryModel in topEntries)
{
    Console.WriteLine($"{logEntryModel.ResourceGroup} had {logEntryModel.Count} events");
}
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection>> QueryBatchAsync (Azure.Monitor.Query.LogsBatchQuery batch, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryBatchAsync : Azure.Monitor.Query.LogsBatchQuery * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection>>
override this.QueryBatchAsync : Azure.Monitor.Query.LogsBatchQuery * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection>>
Public Overridable Function QueryBatchAsync (batch As LogsBatchQuery, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of LogsBatchQueryResultCollection))

パラメーター

batch
LogsBatchQuery

送信する Kusto クエリのバッチ。

cancellationToken
CancellationToken

使用する CancellationToken

戻り値

LogsBatchQueryResultCollectionクエリ結果の取得を許可する 。

適用対象