MetricsQueryClient.QueryResourceAsync Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Interroge les métriques d’une ressource.
string resourceId =
"/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>";
var client = new MetricsQueryClient(new DefaultAzureCredential());
Response<MetricsQueryResult> results = await client.QueryResourceAsync(
resourceId,
new[] { "Average_% Free Space", "Average_% Used Space" }
);
foreach (MetricResult metric in results.Value.Metrics)
{
Console.WriteLine(metric.Name);
foreach (MetricTimeSeriesElement element in metric.TimeSeries)
{
Console.WriteLine("Dimensions: " + string.Join(",", element.Metadata));
foreach (MetricValue value in element.Values)
{
Console.WriteLine(value);
}
}
}
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult>> QueryResourceAsync (string resourceId, System.Collections.Generic.IEnumerable<string> metrics, Azure.Monitor.Query.MetricsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryResourceAsync : string * seq<string> * Azure.Monitor.Query.MetricsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult>>
override this.QueryResourceAsync : string * seq<string> * Azure.Monitor.Query.MetricsQueryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult>>
Public Overridable Function QueryResourceAsync (resourceId As String, metrics As IEnumerable(Of String), Optional options As MetricsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of MetricsQueryResult))
Paramètres
- resourceId
- String
Nom de la ressource.
Par exemple : /subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>
,/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Storage/storageAccounts/mystorage
,/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachines/myvm
- metrics
- IEnumerable<String>
Liste des métriques à interroger.
- options
- MetricsQueryOptions
Options de requête supplémentaires.
- cancellationToken
- CancellationToken
CancellationToken à utiliser.
Retours
Le MetricsQueryResult instance avec les résultats de la requête.
S’applique à
Azure SDK for .NET