Azure App Insights——如何获取经过 AAD 身份验证的访问者的用户 ID 或电子邮件?

Azure App Insights -- How to get the user ID or email for an AAD authenticated visitor?

我有一个 Azure 静态 Web 应用程序和 App Insights 运行 使用此处找到的标准遥测代码集:https://github.com/Microsoft/ApplicationInsights-JS#snippet-setup-ignore-if-using-npm-setup

我想知道如何使用受 AAD 保护的网站获取用户详细信息?我的网站生成身份验证信息,个人可以通过将 /.auth/me 添加到网站 URL 的末尾来访问,看起来像这样,我想知道这是否可能是一种方法。

{
  "clientPrincipal": {
    "identityProvider": "aad",
    "userId": "xxxx",
    "userDetails": "xxxx",
    "userRoles": [
      "authenticated",
      "anonymous"
    ]
  }
}

在相关帖子中,这个帖子似乎与我的兴趣相当相关,但我无法从讨论中得到太多信息:Azure - App Insights - how to track the logged-in Username in Auth Id?

我假设您需要使用受 AAD 保护的网站的用户 ID 详细信息。 以下是了解user ID的步骤及详情:

转到 Application insight > 查看 Application Insights 数据。

转到用户 > 单击查看更多见解

向下滚动到 select 后,如下所示

As Selected Authentication user ID > 点击 User Timeline 查看 USER 的详细信息。

更多信息请参考这个类似的