private static List <MediaOrigin> GetAccountOrigins(MediaServicesAccountConfig account) { var controller = new OriginsController(); var origins = controller.GetOrigins(account); return(origins); }
public int SaveMediaServiceAccount(MediaServicesAccountConfig config) { int added = 0; MediaServicesAccount newAcct = new MediaServicesAccount { AccountName = config.AccountName, SubscriptionName = config.MetaData.AzureSubscriptionId, DataCenter = config.MetaData.ResourceGroup, Location = config.MetaData.Location, AccountCreated = DateTime.UtcNow.Date }; ExecuteWriteQuery(dataContext => { //check for the existing account first var acct = dataContext.MediaServicesAccounts .FirstOrDefault(account => account.AccountName == config.AccountName); if (acct == null) { //only add if the account is not in the db dataContext.MediaServicesAccounts.Add(newAcct); added = dataContext.SaveChanges(); } else { added = acct.AccountId; } }); return(added); }
private static void GetChannelDetails(MediaServicesAccountConfig accountConfig, MediaService accountInfo) { var channelsController = new ChannelsController(); accountInfo.Channels = channelsController.GetAllChannels(accountConfig); accountInfo.Health = accountInfo.Channels.Max(c => c.Health); }
public TelemetryHelper(MediaServicesAccountConfig account, string channelId, string originId) { if (account.TelemetryStorage != null) { var telemetryStorage = new TelemetryStorage(account.TelemetryStorage); if (channelId != null) { _channelId = channelId; _channelMetrics = telemetryStorage.GetRecentChannelMetrics( new Guid(account.Id), new Guid(channelId), 20); } if (originId != null) { _originId = originId; _originMetrics = telemetryStorage.GetRecentStreamingEndpointMetrics( new Guid(account.Id), new Guid(originId.NimbusIdToRawGuid()), 20); } } }
private static AChannel MapMediaChannel( MediaServicesAccountConfig configMediaServicesAccount, MediaService mediaService, MediaChannel mediaChannel ) { var achannel = new AChannel(); string originId = configMediaServicesAccount.OriginMappings .Denull() .Where(x => x.ChannelId == mediaChannel.Id) .Select(x => x.OriginId) .FirstOrDefault(); achannel.Origin = new AOrigin { Id = originId }; achannel.Programs = mediaService.Programs .Denull() .Where(mp => mp.ChannelId == mediaChannel.Id) .Select(mp => new AProgram() { Asset = new AAsset() } ) .ToList(); return(achannel); }
private void GetMetrics(MediaServicesAccountConfig account, List <MediaChannel> channels) { channels.ForEach(channel => channel.EncodingHealth = channel.IngestHealth = channel.ArchiveHealth = channel.OriginHealth = HealthStatus.Ignore); var runningChanels = channels.Where(ch => ch.State == ChannelState.Running.ToString()).ToList(); Parallel.ForEach(runningChanels, (channel) => GetStatusLevel(account, channel)); }
public List <MediaProgram> GetAllPrograms(MediaServicesAccountConfig accountConfig) { var context = accountConfig.GetContext(); var programs = context.Programs.ToList(); var details = programs.Select(GetProgramDetails).ToList(); return(details); }
private void GetAccountDetails(MediaServicesAccountConfig accountConfig, MediaService accountInfo) { var programs = Task.Run(() => GetProgramDetails(accountConfig, accountInfo)); var channels = Task.Run(() => GetChannelDetails(accountConfig, accountInfo)); var origins = Task.Run(() => GetOriginDetails(accountConfig, accountInfo)); Task.WhenAll(channels, origins, programs).Wait(); accountInfo.FindChannelOriginMapping(); }
internal List <MediaChannel> GetAllChannels(MediaServicesAccountConfig account) { var cloudContext = account.GetContext(); var channels = cloudContext.Channels.ToList().OrderBy(ch => ch.Name).ToList(); var channelDetails = channels.Select(channel => GetChannelDetails(account, channel)).ToList(); GetMetrics(account, channelDetails); return(channelDetails); }
private void GetOriginDetails(MediaServicesAccountConfig account, MediaChannel channel) { List <MediaOrigin> origins = GetAccountOrigins(account); var origin = origins.FindOrigin(channel.NameShort); if (origin != null) { channel.OriginId = origin.Id.GuidToOriginId(); } }
internal List <MediaOrigin> GetOrigins(MediaServicesAccountConfig account) { var context = account.GetContext(); var origins = context.StreamingEndpoints.ToList() .OrderBy(e => e.Name) .Select(EntityFactory.BuildOriginFromIStreamingEndpoint) .ToList(); GetMetrics(account, origins); return(origins); }
private void GetStatusLevel(MediaServicesAccountConfig account, MediaChannel channel) { var telemetryHelper = new TelemetryHelper(account, channel.Id, null); if (channel.EncodingType != ChannelEncodingType.None.ToString()) { channel.EncodingHealth = GetEncodingLevel(telemetryHelper); } channel.IngestHealth = GetIngestLevel(telemetryHelper); channel.ArchiveHealth = GetArchiveLevel(telemetryHelper); }
private void FillCustomerDetails(Customer customer, MediaServicesAccountConfig account) { var mediaServicesContext = account.GetContext(); var programs = mediaServicesContext.Programs.ToList(); customer.ProgramCount = programs.Count(); customer.ChannelCount = mediaServicesContext.Channels.Count(); customer.OriginCount = mediaServicesContext.StreamingEndpoints.Count(); customer.ArchiveCount = programs.Count( program => program.State == Microsoft.WindowsAzure.MediaServices.Client.ProgramState.Running); }
private void GetMetrics(MediaServicesAccountConfig account, List <MediaOrigin> origins) { origins.ForEach(origin => origin.Health = HealthStatus.Ignore); var runningOrigins = origins.Where(o => o.State == StreamingEndpointState.Running.ToString()); Parallel.ForEach(runningOrigins, origin => { var telemetryHelper = new TelemetryHelper(account, null, origin.Id); var metrics = telemetryHelper.GetOriginTelemetry(origin.ReservedUnits); origin.Health = metrics.Select(metric => metric.ComputeHealthState().Level).DefaultIfEmpty(HealthStatus.Healthy).Max(); }); }
private void GetProgramDetails(MediaServicesAccountConfig account, List <MediaChannel> channels) { var controller = new ProgramsController(); var programs = controller.GetAllPrograms(account); channels.ForEach(channel => { channel.Programs = programs .Where(program => program.ChannelId == channel.Id) .OrderBy(program => program.State) .ToList(); }); }
public AventusHelper(MediaServicesAccountConfig config) { AccountConfig = config; if (config.TelemetryStorage != null) { TelemetryStorage = new TelemetryStorage(config.TelemetryStorage); } if (config.MetaData.Thumbprint != null) { AventusDNSTail = config.MetaData.aventusDNSBase; Certificate = ChannelCreationOperations.GetCertificate(config.MetaData.Thumbprint); TelemetryClient = ChannelCreationOperations.GetWebClient(null, Certificate); } }
public static CloudMediaContext GetContext(this MediaServicesAccountConfig accountConfig) { var credentials = new MediaServicesCredentials(accountConfig.AccountName, accountConfig.AccountKey); if (accountConfig.MetaData.AcsScope != null) { credentials.Scope = accountConfig.MetaData.AcsScope; credentials.AcsBaseAddress = accountConfig.MetaData.AcsBaseAddress; } var cloudContext = accountConfig.AdminUri != null ? new CloudMediaContext(accountConfig.AdminUri, credentials) : new CloudMediaContext(credentials); return(cloudContext); }
private IActionResult Get(MediaServicesAccountConfig accountConfig, string id) { var chid = string.Format("nb:chid:UUID:{0}", id); AventusTelemetry telemetry = null; var context = accountConfig.GetContext(); var channel = context.Channels.Where(ch => ch.Id == chid).FirstOrDefault(); if (channel == null) { return(NotFound()); } if (channel.EncodingType != ChannelEncodingType.None) { var aventusHelper = new AventusHelper(accountConfig); telemetry = aventusHelper.GetTelemetryInfo(channel); } return(Ok(telemetry)); }
private AventusTelemetry Get(MediaServicesAccountConfig accountConfig, string id) { var chid = string.Format("nb:chid:UUID:{0}", id); AventusTelemetry telemetry = null; var context = accountConfig.GetContext(); var channel = context.Channels.Where(ch => ch.Id == chid).FirstOrDefault(); if (channel == null) { throw new HttpResponseException(System.Net.HttpStatusCode.NotFound); } if (channel.EncodingType != ChannelEncodingType.None) { var aventusHelper = new AventusHelper(accountConfig); telemetry = aventusHelper.GetTelemetryInfo(channel); } return(telemetry); }
private MediaService GetMediaAccountFromCache(Customer customer, MediaServicesAccountConfig accountConfig) { var account = CloudCache.GetAs <MediaService>(accountConfig.Id); if (account != null) { customer.ChannelCount = account.Channels.Count; customer.OriginCount = account.Origins.Count; customer.ProgramCount = account.Programs.Count; customer.ArchiveCount = account.Programs.Where(p => p.State == Sdk.ProgramState.Running.ToString()).Count(); return(new MediaService { Id = account.Id, Name = account.Name, Datacenter = account.Datacenter, Health = account.Health }); } return(null); }
private static ADeployment MapMediaServicesAccounts(MediaServicesAccountConfig configMediaServicesAccount) { var mediaService = MdCache.Instance.GetAs <MediaService>( MediaService.GetCacheKey(configMediaServicesAccount.Id) ); if (null == mediaService) { return(null); } var deployment = new ADeployment(); deployment.Id = configMediaServicesAccount.Id; deployment.AccountName = configMediaServicesAccount.AccountName; deployment.Location = configMediaServicesAccount.MetaData.Location; deployment.Channels = mediaService.Channels .Denull() .Select(mch => MapMediaChannel(configMediaServicesAccount, mediaService, mch)) .ToList(); return(deployment); }
private void GetProgramDetails(MediaServicesAccountConfig accountConfig, MediaService accountInfo) { var programsController = new ProgramsController(); accountInfo.Programs = programsController.GetAllPrograms(accountConfig); }
public AzureMediaService(MediaServicesAccountConfig config) { Config = config; CloudContext = Config.GetContext(); Credentials = new MediaServicesCredentials(Config.AccountName, Config.AccountKey); }
private void GetOriginDetails(MediaServicesAccountConfig account, List <MediaChannel> channels) { List <MediaOrigin> origins = GetAccountOrigins(account); channels.ForEach(channel => GetOriginDetails(account, channel)); }
public TelemetryHelper(MediaServicesAccountConfig account, IChannel channel, IStreamingEndpoint origin = null) : this(account, channel?.Id.NimbusIdToRawGuid(), origin?.Id.NimbusIdToRawGuid()) { }
private MediaChannel GetChannelDetails(MediaServicesAccountConfig account, IChannel ch) { var channel = EntityFactory.BuildChannelFromIChannel(ch); return(channel); }
public ControllerBase() { CloudCache = MdCache.Instance; DataAccess = GetDataAccess(App.Config.Content.ContentProviders[0].MediaServicesSets[0]); DefaultAccount = App.Config.GetDefaultAccount(); }
private void GetOriginDetails(MediaServicesAccountConfig accountConfig, MediaService accountInfo) { var originsController = new OriginsController(); accountInfo.Origins = originsController.GetOrigins(accountConfig); }