How to change Azure Media Encoder reserved unit configuration programatically?

156 views Asked by At

Azure Media Encoder allows you to configure the number and size (Basic/Standard/Premium) of the reserved units on the web interface.

Is there an API to manage this programatically?

1

There are 1 answers

0
George Trifonov On BEST ANSWER

recently released AMS .NET SDK v 3.1.0.0 exposes functionality to change reserved units. Here is a code sample how to update reserve unit:

var encodingBasicReservedUnit = _dataContext.EncodingReservedUnits.FirstOrDefault();
        var initialReservedUnitCount = encodingBasicReservedUnit.CurrentReservedUnits;
        encodingBasicReservedUnit.CurrentReservedUnits = encodingBasicReservedUnit.MaxReservableUnits;
        encodingBasicReservedUnit.Update();
        encodingBasicReservedUnit = _dataContext.EncodingReservedUnits.FirstOrDefault();
        Assert.AreEqual(encodingBasicReservedUnit.CurrentReservedUnits, encodingBasicReservedUnit.MaxReservableUnits,
            "Expecting Encoding ReservedUnit to have increased to Max");
        encodingBasicReservedUnit.CurrentReservedUnits = initialReservedUnitCount;
        encodingBasicReservedUnit.Update();
        encodingBasicReservedUnit = _dataContext.EncodingReservedUnits.FirstOrDefault();
        Assert.AreEqual(encodingBasicReservedUnit.CurrentReservedUnits, initialReservedUnitCount,
            "Expecting Encoding ReservedUnit to have decreased again to initialCount from Max");

More scenario tests can be found in https://github.com/Azure/azure-sdk-for-media-services/blob/dev/test/net/Scenario/EncodingReservedUnitDataTests.cs