【Azure 媒体服务】使用媒体服务 v3 对视频进行上载、编码和流式传输时遇见的AAD错误
2021/4/29 18:56:47
本文主要是介绍【Azure 媒体服务】使用媒体服务 v3 对视频进行上载、编码和流式传输时遇见的AAD错误,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
问题描述
使用媒体服务 v3 对视频进行上载、编码和流式传输示例时,遇见了AAD错误。
TIP: Make sure that you have filled out the appsettings.json file before running this sample. AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct tenant ID. Check with your subscription administrator |
整个示例代码可从GitHub中获取
问题分析
从错误消息来看[AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. ],是代码与中国区的AMS服务认证时候出现的错误,无法找到当前的租户(Tenant),所以需要检查以下两个地方:
- 项目文件中appsettings.json配置的AadEndpoint,ArmAadAudience,ArmEndpoint是否指向了中国区的Endpoint。 代码中默认指向的都是Global地址。
- 在GetCredentialsAsync方法中ApplicationTokenProvider.LoginSilentAsync默认设置到Global,需要改为AzureChina。
问题解决
一:修改appsettings.json中 AadEndpoint,ArmAadAudience,ArmEndpoint 地址
{ "AadClientId": "00000000-0000-0000-0000-000000000000", "AadEndpoint": "https://login.chinacloudapi.cn", "AadSecret": "00000000-0000-0000-0000-000000000000", "AadTenantId": "00000000-0000-0000-0000-000000000000", "AccountName": "amsaccount", "ArmAadAudience": "https://management.core.chinacloudapi.cn/", "ArmEndpoint": "https://management.chinacloudapi.cn/", "Region": "chinaeast", "ResourceGroup": "amsResourceGroup", "SubscriptionId": "00000000-0000-0000-0000-000000000000" }
二:修改ApplicationTokenProvider.LoginSilentAsync方法,指定中国区微软云环境
/// <summary> /// Create the ServiceClientCredentials object based on the credentials /// supplied in local configuration file. /// </summary> /// <param name="config">The parm is of type ConfigWrapper. This class reads values from local configuration file.</param> /// <returns></returns> // <GetCredentialsAsync> private static async Task<ServiceClientCredentials> GetCredentialsAsync(ConfigWrapper config) { // Use ApplicationTokenProvider.LoginSilentWithCertificateAsync or UserTokenProvider.LoginSilentAsync to get a token using service principal with certificate //// ClientAssertionCertificate //// ApplicationTokenProvider.LoginSilentWithCertificateAsync // Use ApplicationTokenProvider.LoginSilentAsync to get a token using a service principal with symetric key ClientCredential clientCredential = new ClientCredential(config.AadClientId, config.AadSecret); return await ApplicationTokenProvider.LoginSilentAsync(config.AadTenantId, clientCredential, ActiveDirectoryServiceSettings.AzureChina); }
参考资料
使用媒体服务 v3 对视频进行上载、编码和流式传输:https://docs.azure.cn/zh-cn/media-services/latest/stream-files-tutorial-with-api
获取访问媒体服务 API 的凭据: https://docs.azure.cn/zh-cn/media-services/latest/access-api-howto?tabs=cli
这篇关于【Azure 媒体服务】使用媒体服务 v3 对视频进行上载、编码和流式传输时遇见的AAD错误的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-01基于Python+Vue开发的医院门诊预约挂号系统
- 2024-10-01基于Python+Vue开发的旅游景区管理系统
- 2024-10-01RestfulAPI入门指南:打造简单易懂的API接口
- 2024-10-01初学者指南:了解和使用Server Action
- 2024-10-01Server Component入门指南:搭建与配置详解
- 2024-10-01React 中使用 useRequest 实现数据请求
- 2024-10-01使用 golang 将ETH账户的资产平均分散到其他账户
- 2024-10-01JWT用户校验课程:从入门到实践
- 2024-10-01Server Component课程入门指南
- 2024-09-30Dnd-Kit学习:新手快速入门指南