zoukankan      html  css  js  c++  java
  • 【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),所以需要检查以下两个地方:

    1. 项目文件中appsettings.json配置的AadEndpoint,ArmAadAudience,ArmEndpoint是否指向了中国区的Endpoint。 代码中默认指向的都是Global地址。
    2. 在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

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    Java中内部类中使用外面变量为什么final修饰?
    Java正则表达式
    Java内部类复习
    MyEclipse建立SpringMVC入门HelloWorld项目
    java中的System类
    java 中的Scanner
    Freemarker判断是否为空
    HQL多种查询实现
    查询功能实现
    EF生成 类型“System.Data.Entity.DbContext”在未被引用的程序集中定义
  • 原文地址:https://www.cnblogs.com/lulight/p/14719005.html
Copyright © 2011-2022 走看看