Azure媒体服务CreateWithHttpMessagesAsync-操作返回了无效的状态码:“ BadRequest”-

时间:2020-01-16 01:21:33

标签: azure azure-functions azure-media-services

我在Azure Media Services v3应用中使用Azure Function v3,并且尝试从https url创建新作业时遇到问题。

我在Azure Function中采用以下方法提交工作。

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;
}

在实际创建作业await client.Jobs.CreateAsync(...的行上失败 并返回异常消息:

操作返回了无效的状态代码“ BadRequest”

堆栈跟踪:

at Microsoft.Azure.Management.Media.JobsOperations.CreateWithHttpMessagesAsync(String resourceGroupName,String accountName,String transformName,String jobName,Job parameters,Dictionary`2 customHeaders,CancellationToken cancelledToken) 在Microsoft.Azure.Management.Media.JobsOperationsExtensions.CreateAsync(IJobsOperations操作,字符串resourceGroupName,字符串accountName,字符串transformName,字符串jobName,作业参数,CancellationToken cancelledToken)

您知道这是什么意思还是如何进一步调试它?

1 个答案:

答案 0 :(得分:4)

我认为问题出在您在创建作业之前没有创建输出资产这一事实。 尝试在创建工作之前添加以下行:

string outputAssetName = jobName;

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

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

另请参阅: https://github.com/Azure-Samples/media-services-v3-dotnet-core-functions-integration/blob/master/LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3/VodFunctions/submit-job.cs