Home > OS >  presetOverride when creating Azure Media Services v3 Job
presetOverride when creating Azure Media Services v3 Job

Time:12-16

When creating an Azure Media Services Job via the REST API, I cannot set a presetOverrides property on the JobOutputAsset as defined in the documentation: https://docs.microsoft.com/en-us/rest/api/media/jobs/create#joboutputasset

My request body is:

{
 "properties": {
    "input": {
      "@odata.type": "#Microsoft.Media.JobInputAsset",
      "assetName": "inputAsset"
    },
    "outputs": [
      {
        "@odata.type": "#Microsoft.Media.JobOutputAsset",
        "assetName": "outputAsset",
        "label": "en-US",
        "presetOverride": {
            "@odata.type": "#Microsoft.Media.AudioAnalyzerPreset",
            "audioLanguage": "en-US",
            "mode": "Basic"
        }
      }
    ],
    "priority" : "Normal"
 }
}

The error message thrown is:

{
    "error": {
        "code": "InvalidResource",
        "message": "The property 'presetOverride' does not exist on type 'Microsoft.Media.JobOutputAsset'. Make sure to only use property names that are defined by the type."
    }
}

When removing the presetOverride data, everything works as expected. The official documentation clearly states that the Microsoft.Media.JobOutputAsset does have a presetOverride property though. What am I doing wrong?

CodePudding user response:

couple of concerns here Rene. I would not recommend using the raw REST API directly for any Azure services. Reason being is that there are a lot of built-in retry scenarios and retry policies that are already rolled into the client SDKs. We've had many customers try to roll their own REST API library but run into massive issues in production because they failed to read up on how to handle and write their own custom retry policy code. Unless you are really familiar with rolling your own retry policies and how Azure Resource Management gateway works, try to avoid it and just use the official client SDKs - see here - https://docs.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#general-rest-and-retry-guidelines

Now, to answer your specific question - try using my sample here in .NET and see if it answers your question. https://github.com/Azure-Samples/media-services-v3-dotnet/blob/3ab85647cbadd2b868aadf175afdede67b40b2fd/AudioAnalytics/AudioAnalyzer/Program.cs#L129

I can also provide a working sample of this in Node.js/Typescript in this repo if you like. It is using the latest 10.0.0 release of our Javascript SDK. I'm working on samples in this repo today - https://github.com/Azure-Samples/media-services-v3-node-tutorials

UPDATE: Added basic audio in Typescript sample. https://github.com/Azure-Samples/media-services-v3-node-tutorials/blob/main/AudioAnalytics/index.ts

Shows how to use the preset override per job.

CodePudding user response:

It is important to select the correct API version when communicating with the Azure Media Services REST API.

In this case, api version 2020-05-01 from the Azure Media Services Postman examples was used. But the presetOverride option is only available starting with version 2021-06-01.

Setting api-version=2021-06-01 as a GET parameter enables Preset Overrides.

  • Related