【问题标题】:Azure Media Services v3 Assets.ListContainerSasAsync returns ApiErrorExceptionAzure 媒体服务 v3 Assets.ListContainerSasAsync 返回 ApiErrorException
【发布时间】:2020-02-25 14:56:23
【问题描述】:

我从 (.net) 中的 Azure 媒体服务 v3 调用 Assets.ListContainerSasAsync,但是,APIErrorException 没有明显原因返回。我已经三重检查了我有有效的 config.ResourceGroup、config.AccountName 和 assetsName 参数。

代码:

AssetContainerSas assetContainerSas = await client.Assets.ListContainerSasAsync(config.ResourceGroup, config.AccountName, assetName, permissions: AssetContainerPermission.Read, expiryTime: DateTime.UtcNow.AddYears(1).ToUniversalTime());

例外:

-       $exception  {"Operation returned an invalid status code 'InternalServerError'"} Microsoft.Azure.Management.Media.Models.ApiErrorException
+       Body    {Microsoft.Azure.Management.Media.Models.ApiError}  Microsoft.Azure.Management.Media.Models.ApiError
+       Data    {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
        HResult -2146233088 int
        HelpLink    null    string
-       InnerException  null    System.Exception
-       Static members      
+       Non-Public members      
        Message "Operation returned an invalid status code 'InternalServerError'"   string
+       Request {Microsoft.Rest.HttpRequestMessageWrapper}  Microsoft.Rest.HttpRequestMessageWrapper
-       Response    {Microsoft.Rest.HttpResponseMessageWrapper} Microsoft.Rest.HttpResponseMessageWrapper
        Content "{\r\n  \"error\": {\r\n    \"code\": \"InternalServerError\",\r\n    \"message\": \"The server encountered an internal error. Please try again later.\"\r\n  }\r\n}"   string
+       Headers Count = 17  System.Collections.Generic.IDictionary<string, System.Collections.Generic.IEnumerable<string>> {System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>}
        ReasonPhrase    "Internal Server Error" string
        StatusCode  InternalServerError System.Net.HttpStatusCode
        Source  "Microsoft.Azure.Management.Media"  string
        StackTrace  "   at Microsoft.Azure.Management.Media.AssetsOperations.<ListContainerSasWithHttpMessagesAsync>d__10.MoveNext()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Azure.Management.Media.AssetsOperationsExtensions.<ListContainerSasAsync>d__11.MoveNext()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at App.MediaLibrary.Service.Services.AzureMediaServicesService.<GetVideoUrlsAsync>d__10.MoveNext() in C:\\Users\\Martin\\Documents\\Projects\\x-a\\b\\c\\MediaLibrary\\Service\\Services\\AzureMediaServicesService.cs:line 108"   string
+       TargetSite  {Void MoveNext()}   System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+       Static members      
+       Non-Public members      

【问题讨论】:

    标签: c# .net exception video-processing azure-media-services


    【解决方案1】:

    问题可能与到期时间有关。根据https://docs.microsoft.com/en-us/rest/api/media/assets/listcontainersas#request-body,expiryTime 必须小于 24 小时。对于长期存在的 SAS URL,请使用 Storage API。

    【讨论】:

    • 你是对的,很好的抓住大卫!我没有意识到我已经在文档中阅读了这个限制。不过,我也很乐意在异常中提供更好的理由...
    猜你喜欢
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多