Azure 媒体服务 CreateWithHttpMessagesAsync - 操作返回无效状态代码 : "BadRequest" -

标签 azure azure-functions azure-media-services

我将 Azure Media Services v3Azure 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(... 并返回异常,并显示以下消息:

Operation returned an invalid status code 'BadRequest'

堆栈跟踪:

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)

知道这意味着什么或者我如何进一步调试它吗?

最佳答案

我认为问题在于您在创建作业之前没有创建输出资源。 尝试在创建作业之前添加这些行:

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

关于Azure 媒体服务 CreateWithHttpMessagesAsync - 操作返回无效状态代码 : "BadRequest" -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59761803/

相关文章:

Azure 媒体服务将多个视频与一个音频流合并

sql - Azure B2C 租户/Active Directory

azure - 找不到 'Connect-Azure' 命令

powershell - 尝试将用户添加到 Office 365 组 (AzureAD)

azure - 如何从 Azure Function App 日志中删除 Azure.Storage.Blobs 日志记录?

azure - 在 Windows Azure 媒体服务中上传和编码音频文件

azure - 自动化测试在 Azure 中失败,但该步骤的结果是通过,这是为什么?

python - Azure Functions Blob 部署

c# - Azure 函数从配置访问连接字符串

c# - 将视频文件从 azure blob 存储上传到 azure 媒体服务