Azure Media Encoder: pricing changes… update your code!

On October 1st It was announced on the official Azure blog a significant change for the price related to the encoding in Microsoft Azure Media Services: From now only be charged for output gigabytes.

What is important to know is that’s not an automatic change, it is necessary to be careful with the processor we are recovering from the platform for this new price. To make it clear, through the following code, we can retrieve the list of processors:

using Microsoft.WindowsAzure.MediaServices.Client;
using System;
using System.Linq;
namespace GetAMSProcessors
    class Program
        static void Main(string[] args)
            //0. Constants
            const string AccountName = "YOUR_MEDIA_ACCOUNT_NAME";
            const string AccountKey = "YOUR_MEDIA_ACCOUNT_KEY";
            //1. Install-Package windowsazure.mediaservices
            //2. Get context
            var context = new CloudMediaContext(AccountName, AccountKey);
            foreach (var processor in context.MediaProcessors.ToList())
                Console.WriteLine(string.Format("{0} {1}", processor.Name, processor.Version));

If we run the above code, we can see that there is more than one processor to the task of encoding, but only one of them is the right one to get the new price today:


It seems obvious but we must be careful because if you use an earlier version of Azure Media Encoder 4.1 we will pay for input and output gigabytes.

That said, we can recover the right processor in two ways:

Using Media extensions

            var processor = context.MediaProcessors.GetLatestMediaProcessorByName("Azure Media Encoder");

Or via the following lambda expression:

var processor = _context.MediaProcessors.Where(p => p.Name == "Azure Media Encoder").ToList().OrderBy(wame => new Version(wame.Version)).LastOrDefault();

Happy encoding!