Azure Fluent API – AppServicePlanOperations.ListMetricsWithHttpMessagesAsync返回InternalServerError
可以在此处找到此方法的文档
这是我的代码:
var appServiceManager = AppServiceManager.Authenticate(credentials, subscriptionId); var filter = "(name.value eq 'CpuPercentage') and startTime eq '2017-10-06T08:00:00Z' and endTime eq '2017-10-06T09:00:00Z' and timeGrain eq duration'PT1H'"; var metrics = appServiceManager.AppServicePlans.Inner.ListMetricsWithHttpMessagesAsync("myResourceGroupName", "myAppServicePlanName", false, filter).Result;
这是我得到的唯一详细例外:
发生了一个或多个错误。 (操作返回无效的状态代码’InternalServerError’)—> Microsoft.Rest.Azure.CloudException:操作返回无效的状态代码’InternalServerError’
文档说过filter
是可选的,它不是(如果我传入null
我得到一个BadRequest)。 我现在提供一个,现在它抛出内部服务器错误。
我已经在azure-sdk-for-net
回购中打开了一个问题,但是我希望其他人可以看到我在我的filter
字符串中是否犯了任何错误。
在使用您提到的代码时,我也可以在我这边重现这个问题。 我发现另一个Microsoft.Azure.Management.Monitor.Fluent SDK可用于列出资源的指标,它是测试版。 我在我身边做了一个演示,它在我身边正常工作。
using Microsoft.Azure.Management.Fluent.ServiceBus; using Microsoft.Azure.Management.Fluent.ServiceBus.Models; using Microsoft.Rest.Azure.Authentication; using Microsoft.Rest.Azure.OData; namespace MonitorDemo { class Program { static void Main(string[] args) { var azureTenantId = "tenant Id"; var azureSecretKey = "secret key"; var azureAppId = "azure AD application Id"; var subscriptionId = "subscription Id"; var resourceGroup = "resource group name"; var servicePlanName = "service plan name"; var serviceCreds = ApplicationTokenProvider.LoginSilentAsync(azureTenantId, azureAppId, azureSecretKey).Result; MonitorClient monitorClient = new MonitorClient(serviceCreds) { SubscriptionId = subscriptionId }; var resourceUri = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverfarms/{servicePlanName}"; // resource id var metricNames = "name.value eq 'CpuPercentage'"; // could be concatenated with " or name.value eq ''" ... inside parentheses for more than one name. // The $filter can include time grain, which is optional when metricNames is present. The is forms a conjunction with the list of metric names described above. string timeGrain = " and timeGrain eq duration'PT5M'"; // The $filter can also include a time range for the query; also a conjunction with the list of metrics and/or the time grain. Defaulting to 3 hours before the time of execution for these datetimes string startDate = " and startTime eq 2017-10-06T08:00:00Z"; string endDate = " and endTime eq 2017-10-06T09:00:00Z"; var odataFilterMetrics = new ODataQuery( $"{metricNames}{timeGrain}{startDate}{endDate}"); var metrics = monitorClient.Metrics.ListWithHttpMessagesAsync(resourceUri, odataFilterMetrics).Result; } } }
packages.config
- 执行测试时出错,如果使用CreateResponse扩展方法返回Azure Function HttpResonseMessage
- 在Azure Function中运行.exe可执行文件
- 如何在Windows Azure(工作器)角色中捕获未处理的exception
- 从VS C#创建Azure SQL数据库时设置服务层
- 为什么我的Azure WebJobs“settings.job”文件被忽略?
- 对于T4模板,这是Azure Queue构造的一个好/可取的模式吗?
- 如何使用System.Net.HttpListener在WebSocket中启用SSL
- 无法加载文件或程序集“System.Net.Http”或其依赖项之一
- C#JsonConvert.DeserializeAnonymousType失败