public Task<ICollection<IStreamingEndPointRequestLog>> GetStreamingEndPointMetricsAsync(
string endpointAddress,
string storageAccountKey,
string mediaServicesAccountId,
string streamingEndPointId,
DateTime start,
DateTime end)
{
if (endpointAddress == null)
{
throw new ArgumentNullException("endpointAddress");
}
if (storageAccountKey == null)
{
throw new ArgumentNullException("storageAccountKey");
}
if (mediaServicesAccountId == null)
{
throw new ArgumentNullException("mediaServicesAccountId");
}
Guid accountId;
if (!Guid.TryParse(mediaServicesAccountId, out accountId))
{
throw new ArgumentException(StringTable.InvalidMediaServicesAccountIdInput);
}
var streamingEndPointGuid = TelemetryUtilities.ParseStreamingEndPointId(streamingEndPointId);
if (start.Kind != DateTimeKind.Utc)
{
throw new ArgumentException(StringTable.NonUtcDateTime, "start");
}
if (end.Kind != DateTimeKind.Utc)
{
throw new ArgumentException(StringTable.NonUtcDateTime, "end");
}
if (start >= end)
{
throw new ArgumentException(StringTable.InvalidTimeRange, "start");
}
var storageAccount = TelemetryUtilities.GetStorageAccountName(endpointAddress);
if (MediaContext.StorageAccounts.Where(c => c.Name == storageAccount).FirstOrDefault() == null)
{
throw new ArgumentException(StringTable.InvalidStorageAccount);
}
return Task.Factory.StartNew(() =>
{
var telemetryStorage = new TelemetryStorage(new StorageCredentials(storageAccount, storageAccountKey), new Uri(endpointAddress));
return telemetryStorage.GetStreamingEndPointMetrics(
accountId,
streamingEndPointGuid,
start,
end);
});
}