/// <summary>
        /// Creates a scheduled job to archive
        /// </summary>
        /// <param name="mediaChannel"></param>
        /// <param name="archivalProgram"></param>
        /// <param name="jobName"></param>
        /// <returns></returns>
        private async Task <Microsoft.WindowsAzure.Scheduler.Models.JobCreateOrUpdateResponse> CreateScheduledJob(IChannel mediaChannel, IProgram archivalProgram, string jobName)
        {
            var cloudServiceName        = NamingHelpers.GetSchedulerCloudServiceName(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceLabel       = NamingHelpers.GetSchedulerCloudServiceLabel(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceDescription = NamingHelpers.GetSchedulerCloudServiceDescription(ServiceConfiguration.MediaServiceAccountName);
            var jobCollectionName       = NamingHelpers.GetSchedulerJobCollectionName(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceRegion      = ServiceConfiguration.SchedulerRegion;

            var bodyParameters = new SchedulerParameters
            {
                ChannelId = mediaChannel.Id,
                ProgramId = archivalProgram.Id,
                JobName   = jobName
            };

            var headers = new Dictionary <string, string>()
            {
                { "Content-Type", "application/json" },
            };

            var nextProgramJob = await SchedulerService.CreateOneTimeHttpJobAsync(
                cloudServiceName,
                jobCollectionName,
                jobName,
                DateTime.UtcNow.AddMinutes(ServiceConfiguration.ArchivalWindowMinutes).AddMinutes(-1 * ServiceConfiguration.OverlappingArchivalWindowMinutes),
                bodyParameters,
                headers,
                "POST",
                ServiceConfiguration.ScheduleManagerEndpoint);

            return(nextProgramJob);
        }
        /// <summary>
        /// Prepares the scheduler
        /// </summary>
        /// <returns></returns>
        private async Task PrepareScheduler()
        {
            var cloudServiceName        = NamingHelpers.GetSchedulerCloudServiceName(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceLabel       = NamingHelpers.GetSchedulerCloudServiceLabel(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceDescription = NamingHelpers.GetSchedulerCloudServiceDescription(ServiceConfiguration.MediaServiceAccountName);
            var jobCollectionName       = NamingHelpers.GetSchedulerJobCollectionName(ServiceConfiguration.MediaServiceAccountName);
            var cloudServiceRegion      = ServiceConfiguration.SchedulerRegion;

            // Create Scheduler Service
            System.Diagnostics.Trace.TraceInformation("Preparing scheduler for Cloud Service [{0}], Job Collection[{1}]", cloudServiceName, jobCollectionName);
            var schedulerService = new SchedulerService(ServiceConfiguration);

            // Create Cloud Service for scheduler (if not exists, otheriwse, returns null)
            System.Diagnostics.Trace.TraceInformation("Creating Cloud Service for scheduler if it doesn't exist");
            var cloudService = await schedulerService.CreateSchedulerCloudServiceIfNotExistsAsync(cloudServiceName, cloudServiceLabel, cloudServiceDescription, cloudServiceRegion);

            // Create a Job Collection (if not exists, otherwise, returns null)
            System.Diagnostics.Trace.TraceInformation("Creating Job Collection for scheduler if it doesn't exist");
            var jobCollection = await schedulerService.CreateJobCollectionIfNotExistsAsync(cloudServiceName, jobCollectionName);
        }