Microsoft.WindowsAzure.MediaServices.Client.StreamingEndPointRequestLogCollection.GetStreamingEndPointMetricsAsync C# (CSharp) Method

GetStreamingEndPointMetricsAsync() public method

Get metrics for a Media Services Streaming EndPoint.
public GetStreamingEndPointMetricsAsync ( string endpointAddress, string storageAccountKey, string mediaServicesAccountId, string streamingEndPointId, System.DateTime start, System.DateTime end ) : Task>
endpointAddress string The Telemetry endpoint address
storageAccountKey string The Storage account key.
mediaServicesAccountId string The Media Services account Id.
streamingEndPointId string The Streaming EndPoint ID
start System.DateTime The start time.
end System.DateTime The end time.
return Task>
        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);
            });
        }