Partager via


Job record limit for Windows Azure Media Encoder

Job record limit for Windows Azure Media Encoder

After processing a large number of videos with the Windows Azure Media Encoder you may see an error in the portal that says, "This account has reached the limit of 50,000 jobs." You see this error when you try to submit a new job. If you are using the REST API or the .Net SDK you see a return of ServiceUnavailable when submitting a job. 

There is a record limit of 50,000 jobs within Windows Azure Media Encoder. You must delete historic job records occasionally to clear up space for new job records. 

Sample Code to Delete Finished Jobs

This C# command line sample code will delete all finished jobs from a single Media Services account. The only parameters that you have to pass are the Media Services account name and key. The sample only deletes jobs that finished (JobState.Finished). If you wish to delete cancelled jobs or jobs that ended with an error, use JobState.Canceled or JobState.Error respectively for the job state.

using System;
using System.Text;
using Microsoft.WindowsAzure.MediaServices.Client; 

namespace DeleteJobs
{
    class Program
    {
        private static CloudMediaContext _context = null;
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                DisplayUsage();
                return;
            }

            Console.Clear();
            Console.WriteLine("Are you sure you want to delete ALL finished jobs?");
            Console.WriteLine("Y/N");
            if (!(Console.ReadKey().Key == ConsoleKey.Y))
            {
                return;
            }

            string accountName = args[0].ToString();
            string accountKey = args[1].ToString();
             _context = new CloudMediaContext(accountName, accountKey); 

            foreach (IJob job in _context.Jobs)
            {
                if (job.State == JobState.Finished)
                {
                    Console.WriteLine("Deleting job {0}", job.Id);
                    job.Delete();
                }
            }
        } 

        static void DisplayUsage()
        {
            Console.Out.WriteLine("\nDeleteFinishedJobs.exe will delete all finished jobs.  There is a limit of");
            Console.Out.WriteLine("50,000 jobs that are allowed to remain in a single Media Services account.");
            Console.Out.WriteLine("Jobs that are processing, queued, or errored out are not deleted.");
            Console.Out.WriteLine("\nUsage:");
            Console.Out.WriteLine("DeleteFinishedJobs.exe <account name> <account key>");
            Console.Out.WriteLine("\n\nExample:\nDeleteJobs.exe testAcct AbCdEfGhIjKlMnOpQrStUvWxYz1234567890=");
        }
    }

 

For more information on the quotas and limitations of Windows Azure Media Services see https://msdn.microsoft.com/en-us/library/jj945161.aspx.