LogsQueryClient.QueryWorkspaceAsync Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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:

C#
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:

C#
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.

C#
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);

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

Azure SDK for .NET Preview ja Azure SDK for .NET Latest
Toode Versioonid
Azure SDK for .NET Latest, Preview

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:

C#
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:

C#
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)));
C#
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);

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

Azure SDK for .NET Preview ja Azure SDK for .NET Latest
Toode Versioonid
Azure SDK for .NET Latest, Preview