LogsQueryClient.QueryResource Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Sobrecargas
QueryResource(ResourceIdentifier, String, QueryTimeRange, LogsQueryOptions, CancellationToken) |
Retorna todos os logs do Azure Monitor que correspondem à consulta fornecida para um recurso do Azure.
|
QueryResource<T>(ResourceIdentifier, String, QueryTimeRange, LogsQueryOptions, CancellationToken) |
Retorna todos os logs do Azure Monitor que correspondem à consulta fornecida para um recurso do Azure.
|
QueryResource(ResourceIdentifier, String, QueryTimeRange, LogsQueryOptions, CancellationToken)
- Origem:
- LogsQueryClient.cs
- Origem:
- LogsQueryClient.cs
Retorna todos os logs do Azure Monitor que correspondem à consulta fornecida para um recurso do Azure.
var client = new LogsQueryClient(new DefaultAzureCredential());
string resourceId = "/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>";
string tableName = "<table_name>";
Response<LogsQueryResult> results = await client.QueryResourceAsync(
new ResourceIdentifier(resourceId),
$"{tableName} | distinct * | project TimeGenerated",
new QueryTimeRange(TimeSpan.FromDays(7)));
LogsTable resultTable = results.Value.Table;
foreach (LogsTableRow row in resultTable.Rows)
{
Console.WriteLine($"{row["OperationName"]} {row["ResourceGroup"]}");
}
foreach (LogsTableColumn columns in resultTable.Columns)
{
Console.WriteLine("Name: " + columns.Name + " Type: " + columns.Type);
}
public virtual Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult> QueryResource (Azure.Core.ResourceIdentifier resourceId, string query, Azure.Monitor.Query.QueryTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryResource : Azure.Core.ResourceIdentifier * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult>
override this.QueryResource : Azure.Core.ResourceIdentifier * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.LogsQueryResult>
Public Overridable Function QueryResource (resourceId As ResourceIdentifier, query As String, timeRange As QueryTimeRange, Optional options As LogsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of LogsQueryResult)
Parâmetros
- resourceId
- ResourceIdentifier
A ID do recurso do Azure em que a consulta deve ser executada.
- query
- String
A consulta Kusto para buscar os logs.
- timeRange
- QueryTimeRange
O período para o qual os logs devem ser pesquisados.
- options
- LogsQueryOptions
O LogsQueryOptions para configurar a consulta.
- cancellationToken
- CancellationToken
O CancellationToken a ser usado.
Retornos
Os logs que correspondem à consulta.
Comentários
Quando o timeRange
argumento é All e o query
argumento contém um filtro de intervalo de tempo, o serviço subjacente usa o intervalo de tempo especificado em query
.
Aplica-se a
QueryResource<T>(ResourceIdentifier, String, QueryTimeRange, LogsQueryOptions, CancellationToken)
- Origem:
- LogsQueryClient.cs
- Origem:
- LogsQueryClient.cs
Retorna todos os logs do Azure Monitor que correspondem à consulta fornecida para um recurso do Azure.
var client = new LogsQueryClient(new DefaultAzureCredential());
string resourceId = "/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>";
string tableName = "<table_name>";
Response<LogsQueryResult> results = await client.QueryResourceAsync(
new ResourceIdentifier(resourceId),
$"{tableName} | distinct * | project TimeGenerated",
new QueryTimeRange(TimeSpan.FromDays(7)));
LogsTable resultTable = results.Value.Table;
foreach (LogsTableRow row in resultTable.Rows)
{
Console.WriteLine($"{row["OperationName"]} {row["ResourceGroup"]}");
}
foreach (LogsTableColumn columns in resultTable.Columns)
{
Console.WriteLine("Name: " + columns.Name + " Type: " + columns.Type);
}
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<T>> QueryResource<T> (Azure.Core.ResourceIdentifier resourceId, string query, Azure.Monitor.Query.QueryTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryResource : Azure.Core.ResourceIdentifier * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> Azure.Response<System.Collections.Generic.IReadOnlyList<'T>>
override this.QueryResource : Azure.Core.ResourceIdentifier * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions * System.Threading.CancellationToken -> Azure.Response<System.Collections.Generic.IReadOnlyList<'T>>
Public Overridable Function QueryResource(Of T) (resourceId As ResourceIdentifier, query As String, timeRange As QueryTimeRange, Optional options As LogsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of IReadOnlyList(Of T))
Parâmetros de tipo
- T
Parâmetros
- resourceId
- ResourceIdentifier
A ID do recurso do Azure em que a consulta deve ser executada.
- query
- String
A consulta Kusto para buscar os logs.
- timeRange
- QueryTimeRange
O período para o qual os logs devem ser pesquisados.
- options
- LogsQueryOptions
O LogsQueryOptions para configurar a consulta.
- cancellationToken
- CancellationToken
O CancellationToken a ser usado.
Retornos
Os logs que correspondem à consulta.
Aplica-se a
Azure SDK for .NET