Azure 媒体服务 v3 Assets.ListContainerSasAsync returns ApiErrorException
Azure Media Services v3 Assets.ListContainerSasAsync returns ApiErrorException
我在 (.net) 中从 Azure Media Services v3 调用 Assets.ListContainerSasAsync,但是没有明显原因返回 APIErrorException。我已经三重检查了 config.ResourceGroup、config.AccountName 和 assetName 参数是否有效。
代码:
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
问题可能与到期时间有关。根据 https://docs.microsoft.com/en-us/rest/api/media/assets/listcontainersas#request-body,expiryTime 必须小于 24 小时。对于长期存在的 SAS URL,请使用存储 API.
我在 (.net) 中从 Azure Media Services v3 调用 Assets.ListContainerSasAsync,但是没有明显原因返回 APIErrorException。我已经三重检查了 config.ResourceGroup、config.AccountName 和 assetName 参数是否有效。
代码:
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
问题可能与到期时间有关。根据 https://docs.microsoft.com/en-us/rest/api/media/assets/listcontainersas#request-body,expiryTime 必须小于 24 小时。对于长期存在的 SAS URL,请使用存储 API.