你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

LogsQueryClient.QueryWorkspaceAsync 方法

定义

重载

QueryWorkspaceAsync(String, String, QueryTimeRange, LogsQueryOptions, CancellationToken)

执行日志查询。

QueryWorkspaceAsync<T>(String, String, QueryTimeRange, LogsQueryOptions, CancellationToken)

执行日志查询。 如果查询返回单个列,则将结果反序列化为强类型模型类或基元类型。

查询模型的示例:

Response<IReadOnlyList<MyLogEntryModel>> response = await client.QueryWorkspaceAsync<MyLogEntryModel>(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count",
    new QueryTimeRange(TimeSpan.FromDays(1)));

查询基元的示例:

Response<IReadOnlyList<string>> response = await client.QueryWorkspaceAsync<string>(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count | project ResourceGroup",
    new QueryTimeRange(TimeSpan.FromDays(1)));

QueryWorkspaceAsync(String, String, QueryTimeRange, LogsQueryOptions, CancellationToken)

Source:
LogsQueryClient.cs
Source:
LogsQueryClient.cs

执行日志查询。

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult>> QueryWorkspaceAsync (string workspaceId, string query, Azure.Monitor.Query.QueryTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryWorkspaceAsync : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult>>
override this.QueryWorkspaceAsync : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult>>
Public Overridable Function QueryWorkspaceAsync (workspaceId As String, query As String, timeRange As QueryTimeRange, Optional options As LogsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of LogsQueryResult))

参数

workspaceId
String

要包含在查询 () xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 的工作区 ID。

query
String

用于提取日志的 Kusto 查询。

timeRange
QueryTimeRange

应查找日志的时间段。

options
LogsQueryOptions

LogsQueryOptions 配置查询的 。

cancellationToken
CancellationToken

要使用的 CancellationToken

返回

LogsQueryResult包含查询结果的 。

注解

timeRange当 参数为 Allquery 参数包含时间范围筛选器时,基础服务将使用 中指定的query时间范围。

适用于

QueryWorkspaceAsync<T>(String, String, QueryTimeRange, LogsQueryOptions, CancellationToken)

Source:
LogsQueryClient.cs
Source:
LogsQueryClient.cs

执行日志查询。 如果查询返回单个列,则将结果反序列化为强类型模型类或基元类型。

查询模型的示例:

Response<IReadOnlyList<MyLogEntryModel>> response = await client.QueryWorkspaceAsync<MyLogEntryModel>(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count",
    new QueryTimeRange(TimeSpan.FromDays(1)));

查询基元的示例:

Response<IReadOnlyList<string>> response = await client.QueryWorkspaceAsync<string>(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count | project ResourceGroup",
    new QueryTimeRange(TimeSpan.FromDays(1)));
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<T>>> QueryWorkspaceAsync<T> (string workspaceId, string query, Azure.Monitor.Query.QueryTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryWorkspaceAsync : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<'T>>>
override this.QueryWorkspaceAsync : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<'T>>>
Public Overridable Function QueryWorkspaceAsync(Of T) (workspaceId As String, query As String, timeRange As QueryTimeRange, Optional options As LogsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of T)))

类型参数

T

参数

workspaceId
String

要包含在查询 () xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 的工作区 ID。

query
String

用于提取日志的 Kusto 查询。

timeRange
QueryTimeRange

应查找日志的时间段。

options
LogsQueryOptions

LogsQueryOptions 配置查询的 。

cancellationToken
CancellationToken

要使用的 CancellationToken

返回

映射到类型 T的查询结果。

注解

timeRange当 参数为 Allquery 参数包含时间范围筛选器时,基础服务将使用 中指定的query时间范围。

适用于