LogsQueryClient.QueryWorkspaceAsync Method

Definition

Overloads

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

Executes the logs query.

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

Executes the logs query. Deserializes the result into a strongly typed model class or a primitive type if the query returns a single column.

Example of querying a model:

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

Example of querying a primitive:

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

Executes the logs query.

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))

Parameters

workspaceId
String

The workspace ID to include in the query (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

query
String

The Kusto query to fetch the logs.

timeRange
QueryTimeRange

The time period for which the logs should be looked up.

options
LogsQueryOptions

The LogsQueryOptions to configure the query.

cancellationToken
CancellationToken

The CancellationToken to use.

Returns

The LogsQueryResult with the query results.

Remarks

When the timeRange argument is All and the query argument contains a time range filter, the underlying service uses the time range specified in query.

Applies to

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

Source:
LogsQueryClient.cs
Source:
LogsQueryClient.cs

Executes the logs query. Deserializes the result into a strongly typed model class or a primitive type if the query returns a single column.

Example of querying a model:

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

Example of querying a primitive:

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)))

Type Parameters

T

Parameters

workspaceId
String

The workspace ID to include in the query (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

query
String

The Kusto query to fetch the logs.

timeRange
QueryTimeRange

The time period for which the logs should be looked up.

options
LogsQueryOptions

The LogsQueryOptions to configure the query.

cancellationToken
CancellationToken

The CancellationToken to use.

Returns

Query results mapped to a type T.

Remarks

When the timeRange argument is All and the query argument contains a time range filter, the underlying service uses the time range specified in query.

Applies to