【发布时间】:2022-01-12 02:13:06
【问题描述】:
我必须在 C# 上编写一个程序来获取有关 Azure APIM 的一些 api 的信息,我可以通过 api 来实现吗?
【问题讨论】:
标签: c# azure api azure-api-management
我必须在 C# 上编写一个程序来获取有关 Azure APIM 的一些 api 的信息,我可以通过 api 来实现吗?
【问题讨论】:
标签: c# azure api azure-api-management
您可以尝试的一种解决方法是从存储 API 管理指标的 Azure Monitor 获取查看的诊断数据
用于列出资源的指标
IEnumerable<Metric> metrics = await readOnlyClient.Metrics.ListAsync(resourceUri: resourceUri, cancellationToken: CancellationToken.None);
或使用过滤器
// The comma-separated list of metric names must be present if a filter is used
var metricNames = "name.value eq 'CpuPercentage'"; // could be concatenated with " or name.value eq '<another name>'" ...
// Time grain is optional when metricNames is present
string timeGrain = " and timeGrain eq duration'PT5M'";
// Defaulting to 3 hours before the time of execution for these datetimes
string startDate = string.Format(" and startTime eq {0}", DateTime.Now.AddHours(-3).ToString("o"));
string endDate = string.Format(" and endTime eq {0}", DateTime.Now.ToString("o"));
var odataFilterMetrics = new ODataQuery<Metric>(
string.Format(
"{0}{1}{2}{3}",
metricNames,
timeGrain,
startDate,
endDate));
Write("Call with filter parameter (i.e. $filter = {0})", odataFilterMetrics);
metrics = await readOnlyClient.Metrics.ListAsync(resourceUr
参考:
【讨论】: