Azure Media Services not picking up thumbnail job

Category: azure media services


Jordan_Clipcopia on Tue, 03 Sep 2013 19:46:31


We currently have Azure Media Services setup to work with a queue that stores jobs in a blob storage table. Our worker role picks up these jobs. Suddenly, the thumbnail jobs placed in the storage queue are not being picked up. We have a "H264 Broadband 720p" preset that is processing fine. 

Azure Media Services SDK v2.0.1.0

Here is our code for creating a job: 

 public static string CreateNewEncodingJob(string jobType, string assetId)
            if (_context == null) Initialize();

            // Read the preset configuration data into a string. 
            //string xmlPreset = File.ReadAllText(Path.GetFullPath(configFilePath + @"\Thumbnail.xml"));
            if (jobType == "thumbnail")
                jobType = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + @"
<Thumbnail Size=" + "\"141,95\" Type=\"Jpeg\" Filename=\"{OriginalFilename}_{ThumbnailTime}.{DefaultExtension}\">" + @"
  <Time Value=" + "\"0:0:0\"/>" + @"
  <Time Value=" + "\"0:0:3\" Step=\"0:0:0.25\" Stop=\"0:0:10\"/>" + @"

            IAsset asset = GetAsset(assetId);
            if (asset == null)
                return null;

            // Declare a new job.
            IJob job = _context.Jobs.Create("My Thumbnail job");
            // Get a media processor reference, and pass to it the name of the 
            // processor to use for the specific task.
            IMediaProcessor processor = GetMediaProcessor("Windows Azure Media Encoder", "");

            // Create a task with the encoding details, using a configuration file with presets.
            ITask task = job.Tasks.AddNew("My thumbnail task",
            // Specify the input asset to be encoded.
            // Add an output asset to contain the results of the job.
            task.OutputAssets.AddNew("Output asset",

            // Launch the job. 

            return job.Id;

Here is the code from our Worker Role to pick up the job:

public void DoMediaProcessingWork()
            if (Convert.ToBoolean(RoleEnvironment.GetConfigurationSettingValue("RunMediaServicesProcessing")))

                while (true)

                        // Check for messages in our relevant queues.. first look for new assets
                        CloudQueueMessage msg = CloudQueueManager.CheckForMessages("newasset");


                        if (msg != null)
                            // If there are any, create the initial media services jobs for them and create references of them in table storage for tracking
                            var messageParts = msg.AsString.Split(new char[] { ',' });
                            //(tenantId + "," + clipId + "," + assetId);
                            int tenantId = Convert.ToInt32(messageParts[0]);
                            int clipId = Convert.ToInt32(messageParts[1]);
                            var assetId = messageParts[2];

                            // Ok now create any new encoding jobs we require
                            string[] jobTypes = new string[] { "thumbnail", "H264 Broadband 720p" };

                            foreach (string jobType in jobTypes)
                                    string jobId = CloudMediaServices.CreateNewEncodingJob(jobType, assetId);
                                    if (jobId != null)
                                        CloudEncodingJob job = new CloudEncodingJob(tenantId, clipId, assetId, jobId, jobType);
                                        Trace.WriteLine("Creating new job for tenantId: " + tenantId + " clipId: " + clipId + " assetId: " + assetId + " jobId: " + jobId + " jobType: " + jobType);

                                        // And now register the job in azure table storage

                                        // And signal that it needs to be monitored
                                        Trace.TraceError("Unable to create new encoding job: " + jobType + " for asset: " + assetId);
                                catch (Exception ee)

                            // Delete this message
                            CloudQueueManager.DeleteMessage("newasset", msg);

Any advice as to why these jobs are not being handled by our worker role. 


George Trifonov on Tue, 03 Sep 2013 20:15:47

Can you please provide any exception if you get one.
 According to your logic system will not add anything if it will not be able to find asset.
IAsset asset = GetAsset(assetId);
if (asset == null)
return null;
I would recommend to add try catch on job.Submit statement and log error their. Once job has been created you can query job by id to see if any errors happens during it's execution.