1
votes

I am using Azure Media Services v3 with an Azure Function v3 app and am running into an issue when trying to create a new job from an https url.

I have the following method in the Azure Function that submits a job.

private static async Task<Job> SubmitJobAsync(IAzureMediaServicesClient client, string transformNam, string jobName, string fileUrl) {
    JobInputHttp jobInput = new JobInputHttp(files: new [] { fileUrl });
    JobOutput[] jobOutputs = 
    {
        new JobOutputAsset(jobName)
    }

    Job job = await client.Jobs.CreateAsync(
        _resourceGroupName,
        _accountName,
        transformName,
        jobName,
        new Job
        {
            Input = jobInput,
            Outputs = jobOutputs
        },
        CancellationToken.None);

    return job;
}

It's failing on the line that actually creates the job await client.Jobs.CreateAsync(... and is returning an exception with a message of:

Operation returned an invalid status code 'BadRequest'

Stack Trace:

at Microsoft.Azure.Management.Media.JobsOperations.CreateWithHttpMessagesAsync(String resourceGroupName, String accountName, String transformName, String jobName, Job parameters, Dictionary`2 customHeaders, CancellationToken cancellationToken) at Microsoft.Azure.Management.Media.JobsOperationsExtensions.CreateAsync(IJobsOperations operations, String resourceGroupName, String accountName, String transformName, String jobName, Job parameters, CancellationToken cancellationToken)

Any idea what this means or how I can further debug this?

1
Can you offer the code in your function? How do you invoke your method? Please show more details. - Cindy Pau

1 Answers

6
votes

I think the problem comes from the fact that you did not create the Output Asset before creating the job. Try to add these lines before the job creation :

string outputAssetName = jobName;

Asset outputAsset = await client.Assets.CreateOrUpdateAsync(_resourceGroupName, _accountName, outputAssetName, new Asset());

JobOutput[] jobOutputs = 
        {
            new JobOutputAsset(outputAssetName)
        }

See also : https://github.com/Azure-Samples/media-services-v3-dotnet-core-functions-integration/blob/master/LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3/VodFunctions/submit-job.cs