【问题标题】:Managed Identity for Azure AppService with Graph API使用 Graph API 的 Azure AppService 托管标识
【发布时间】:2020-06-04 16:38:07
【问题描述】:

我需要实施“托管身份

来源:应用服务
目的地:图形 API
类型:托管身份 => 用户身份

使用用户身份为 AppService 实现 MI 以调用 Graph API 的步骤是什么。需要调用 Graph API 来获取用户的安全组。

我正在使用 C# 和 ASP.net MVC。你能指导一下吗?

【问题讨论】:

    标签: azure-managed-identity


    【解决方案1】:

    将用户管理的身份链接到应用服务后(参见步骤here),您可以使用Microsoft.Azure.Services.AppAuthentication 从C# 中使用它。您将找到示例 here(在执行 GetAccessTokenAsync 时,您需要传递图形的资源 ID)。

    如果您想调用访问用户信息,您很可能会遇到权限问题(托管身份可能没有访问用户信息的权限)。如果是这种情况,您应该使用应用程序而不是托管标识来使用On-Behalf Of flow

    【讨论】:

    • Abinash Tumul,有帮助吗?
    【解决方案2】:

    不是 C#,但对于那些有兴趣通过 @azure/identity Node SDK 访问带有托管标识的 Microsoft Graph API 的人

    import { DefaultAzureCredential } from '@azure/identity';
    const authToken = await credential.getToken(['https://graph.microsoft.com/']);
    const response = await fetch('https://graph.microsoft.com/v1.0/me', {
                headers: { Authorization: authToken.token }
            });
    console.log(await response.text());
    

    【讨论】:

      猜你喜欢
      • 2020-05-02
      • 2022-06-14
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 2022-11-11
      • 2019-03-04
      • 2020-12-30
      相关资源
      最近更新 更多