上传时Azure Media Services瞬态错误

时间:2016-01-08 18:36:36

标签: azure azure-media-services

当我通过C#api代码上传时,我得到以下内容。 (它似乎在门户网站上运行良好)

TransientSystem:发生了瞬态错误。我们对不便表示抱歉。请再试一次。

我找不到任何相关内容,显然它并没有告诉我任何事情。

这是我的代码:`var account = GetAzureAccount();             var client = account.CreateCloudBlobClient();

        var sourceContainer = await GetAzureContainer(account, ResourceUtilities.VideoResources, false);

        var sourceBlob = GetBlockBlob(sourceContainer, videoResource);

        var context = GetMediaContext();
        IAsset asset = context.Assets.Create(GetAzureBlobName(videoResource), AssetCreationOptions.None);

        try
        {
            IAccessPolicy writePolicy = context.AccessPolicies.Create("writePolicy", TimeSpan.FromHours(24), AccessPermissions.Write);
            ILocator destinationLocator = context.Locators.CreateLocator(LocatorType.Sas, asset, writePolicy);

            // Get the asset container URI and Blob copy from mediaContainer to assetContainer. 
            string destinationContainerName = (new Uri(destinationLocator.Path)).Segments[1];

            CloudBlobContainer assetContainer = client.GetContainerReference(ResourceUtilities.MediaAssets);
            if (assetContainer.CreateIfNotExists())
            {
                assetContainer.SetPermissions(new BlobContainerPermissions
                {
                    PublicAccess = BlobContainerPublicAccessType.Off
                });
            }

            var assetFile = asset.AssetFiles.Create(sourceBlob.Name + "-source");
            CopyBlob(sourceBlob, assetContainer);
            assetFile.ContentFileSize = sourceBlob.StreamWriteSizeInBytes;
            assetFile.Update();
            destinationLocator.Delete();
            writePolicy.Delete();

            //Now encode it
            IJob job = context.Jobs.Create("Media Encoder Standard");
            var processor = GetLatestMediaProcessorByName(context, "Media Encoder Standard");
            var task = job.Tasks.AddNew("Encode " + videoResource.FileName, processor, "H264 Multiple Bitrate 720p", TaskOptions.None);

            task.InputAssets.Add(asset);
            task.OutputAssets.AddNew(System.IO.Path.GetFileNameWithoutExtension(videoResource.FileName) + "-production" + System.IO.Path.GetExtension(videoResource.FileName), AssetCreationOptions.None);

            job.StateChanged += Job_StateChanged;
            await job.SubmitAsync();
            await job.GetExecutionProgressTask(CancellationToken.None);
            var finalAsset = job.OutputMediaAssets[0];
            if (job.State == JobState.Error)
            {
                await finalAsset.DeleteAsync();
                throw new InvalidOperationException(string.Join("\r\n", job.Tasks.SelectMany(t => t.ErrorDetails).Select(ed => ed.Message).ToArray()));
            }`

它从那里继续但在作业状态错误上失败。

这很大程度上是从样本中复制出来的,所以我很茫然。有人有建议吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

对于那些得到这个无用错误的人,我确定每当资产没有资产容器中的blob与资产文件中的blob完全相同时,就会得到它。修复它,这两个是相同的,它的工作原理。

在我看来,如果资产文件直接链接到blob(并从blob继承),这将会更好地工作,这样就不会发生这种情况,并且两者之间存在强大的非字符串链接(即assetfile应该只是它背后的blob的扩展名

同时向媒体团队提出建议:将此文件抛出404文件未找到错误,但未找到信息和文件名,以便进行调试。