zoukankan      html  css  js  c++  java
  • 【Azure Developer】在微软云中国区,如何使用Microsoft GraphAPI连接到B2C Tenant

    问题描述

    如题所述,当在中国区使用Microsoft GraphAPI连接B2C Tenant时候,如何来设置中国区的Endpoint呢?在GitHub的示例中,并没有示例介绍如何连接中国区。如

    问题解决

    由于中国区的Azure是独立的运行环境,所以与Global不一样。在终结点方面表现最为明显,如在使用China Azure的开发中,需要特别注意终结点部分:

    结合示例代码,修改成指向中国区的代码为:

                AppSettings config = AppSettingsFile.ReadFromJsonFile();
    
                // Initialize the client credential auth provider
                IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                    .Create(config.AppId)
                    .WithTenantId(config.TenantId)
                    .WithClientSecret(config.ClientSecret)
                    .Build();
                ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication, "https://microsoftgraph.chinacloudapi.cn/.default");
                
                // Set up the Microsoft Graph service client with client credentials
                var httpClient = GraphClientFactory.Create(authProvider, nationalCloud: GraphClientFactory.China_Cloud);
                GraphServiceClient graphClient = new GraphServiceClient(httpClient);
                graphClient.BaseUrl = "https://microsoftgraph.chinacloudapi.cn/v1.0";

    注意: 如果在运行代码时,遇见权限不足的问题,需要先确认AAD中所注册的应用(Registrations Application)是否有Microsoft Graph的相关权限.

    参考资料

    中国区 Azure 开发人员入门指南https://docs.azure.cn/zh-cn/guides/developer/azure-developer-guide

    Microsoft Graph .NET Authentication Provider Libraryhttps://github.com/microsoftgraph/msgraph-sdk-dotnet-auth

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

  • 相关阅读:
    格式控制符
    sort快速排序法
    堆积排序
    oracle常用命令
    C#中int和System.Int32理解总结
    IIS 7.5中的配置
    WPF循序渐进:XAML入门 .
    怎样找到excel两列之间同行相同的数据
    pl/sql functions and cbo costing
    Oracle 学习纲要
  • 原文地址:https://www.cnblogs.com/lulight/p/14666413.html
Copyright © 2011-2022 走看看