我正在使用Partner Center SDK“获取Azure的客户利用率记录”功能。必须逐页请求数据。但是在首先请求下一页后我有错误。
这是我的代码和结果:
var partnerOperations = UserPartnerOperations;
var toTime = DateTimeOffset.Now;
var fromTime = DateTimeOffset.Now.AddDays(-10);
var utilizationRecords = partnerOperations.Customers[customerId].Subscriptions[subscriptionId]
.Utilization.Azure.Query(
fromTime,
toTime,
size: 10,
granularity: AzureUtilizationGranularity.Daily);
var utilizationRecordEnumerator = partnerOperations.Enumerators.Utilization.Azure.Create(utilizationRecords);
var pageNumber = 1;
while (utilizationRecordEnumerator.HasValue)
{
Console.WriteLine("PageNumber: {0}", pageNumber++);
var page = utilizationRecordEnumerator.Current;
foreach (var utilizationRecord in page.Items)
{
Console.WriteLine("UsageStartTime:{0:s} UsageEndTime:{1:s} Name:{2} Quantity:{3}",
utilizationRecord.UsageStartTime.UtcDateTime,
utilizationRecord.UsageEndTime.UtcDateTime,
utilizationRecord.Resource.Name,
utilizationRecord.Quantity);
}
utilizationRecordEnumerator.Next(); // Line 239
}
Microsoft.Store.PartnerCenter.Exceptions.PartnerException : Exception of type 'Microsoft.Store.PartnerCenter.Exceptions.PartnerException' was thrown.
at Microsoft.Store.PartnerCenter.PartnerService.SynchronousExecute(Func`1 operation)
at MSPControl.Providers.o365.Api.PartnerCenterApiClient.GetAzureUtilizationRecordsOrigin(String customerId, String subscriptionId, DateTimeOffset startTime, DateTimeOffset endTime, UtilizationGranularity granularity) in E:\_Projects\MSPControl\MSPControl\Sources\MSPControl.Providers.o365.Api\PartnerCenterApiClient.cs:**line 239**
at MSPControl.Providers.o365.Api.Tests.PartnerCenterApiClientTests.SaveUtilizationRecordsTest() in E:\_Projects\MSPControl.Tests\MSPControl.Providers.MicrosoftOnline.Tests\PartnerCenterApiClientTests.cs:line 82
PageNumber: 1
UsageStartTime:2017-01-13T00:00:00 UsageEndTime:2017-01-14T00:00:00 Name:Standard Small App Service Hours Quantity:3.0
UsageStartTime:2017-01-13T00:00:00 UsageEndTime:2017-01-14T00:00:00 Name:Basic Database Days Quantity:0.166666666666667
UsageStartTime:2017-01-13T00:00:00 UsageEndTime:2017-01-14T00:00:00 Name:Free App Service Quantity:0.004032
UsageStartTime:2017-01-13T00:00:00 UsageEndTime:2017-01-14T00:00:00 Name:Basic Database Days Quantity:0.208333333333333
UsageStartTime:2017-01-14T00:00:00 UsageEndTime:2017-01-15T00:00:00 Name:Standard Small App Service Hours Quantity:24.0
UsageStartTime:2017-01-14T00:00:00 UsageEndTime:2017-01-15T00:00:00 Name:Basic Database Days Quantity:0.833333333333333
UsageStartTime:2017-01-14T00:00:00 UsageEndTime:2017-01-15T00:00:00 Name:Free App Service Quantity:0.032256
UsageStartTime:2017-01-14T00:00:00 UsageEndTime:2017-01-15T00:00:00 Name:Basic Database Days Quantity:1.0
UsageStartTime:2017-01-15T00:00:00 UsageEndTime:2017-01-16T00:00:00 Name:Standard Small App Service Hours Quantity:21.0
UsageStartTime:2017-01-15T00:00:00 UsageEndTime:2017-01-16T00:00:00 Name:Free App Service Quantity:0.028224