本教程介绍如何 使用来自 Microsoft Entra 的数据在 Azure 数据资源管理器中创建自定义报表 ,演示如何使用来自 Microsoft Entra ID 和 Microsoft Entra ID 治理服务的数据在 Azure 数据资源管理器 中创建自定义报表。
还可以将数据从 Microsoft Entra 以外的源引入 Azure 数据资源管理器。 此功能的方案包括:
- 管理员希望查看审核日志中的事件,其中包含有关用户、访问包或其他不属于审核记录本身的对象的其他详细信息。
- 管理员希望查看从Microsoft Entra ID 添加到应用程序的所有用户及其在应用程序自己的存储库(例如 SQL 数据库)中的访问权限。
这些类型的报表不会内置到 Microsoft Entra ID 中。 您可以通过从 Microsoft Entra ID 提取数据,并在 Azure 数据资源管理器中使用自定义查询合并数据,自己创建这些报表。
在 Azure Monitor 中查询数据
如果要将审核、登录或其他Microsoft Entra 日志发送到 Azure Monitor,则可以将这些日志从该 Azure Monitor Log Analytics 工作区合并到查询中,而无需将数据复制到 Azure 数据资源管理器中。 有关 Azure Monitor 与 Azure 数据资源管理器之间的关系的详细信息,请参阅 使用 Azure 数据资源管理器在 Azure Monitor 中查询数据。
此示例以从 Microsoft Entra ID 治理填充 Azure 数据资源管理器的教程为基础,演示如何将 Azure Monitor 中存储的 Microsoft Entra 审核日志(作为 AuditLogs
)与 Azure 数据资源管理器中存储的 Microsoft Entra 访问包(作为 EntraAccessPackages
)进行联接。
登录到 Microsoft Entra 管理中心。
选择“诊断设置”。
选择要在其中发送日志的 Log Analytics 工作区。
在 Log Analytics 工作区概述中,记录订阅 ID、资源名称和工作区的名称。
登录到 Azure 门户。
确保您的 Azure 数据资源管理器群集已在列表中显示。
选择“+ 添加”>“连接”。
在 “添加连接” 窗口中,输入 Log Analytics 工作区中的 URL。 URL 由特定于云的主机名、订阅 ID、资源组名称和 Azure Monitor Log Analytics 工作区的工作区名称组成,如 “添加 Log Analytics 工作区”中所述。
建立连接后,Log Analytics 工作区会显示在左侧窗格中,其中包含本机 Azure 数据资源管理器群集。
选择 “查询”,然后选择 Azure 数据资源管理器群集。
在查询窗格中,请参阅包含 Azure 数据资源管理器查询中Microsoft Entra 日志的 Azure Monitor 表。 例如:
let CL1 = 'https://ade.loganalytics.io/subscriptions/*subscriptionid*/resourcegroups/*resourcegroupname*/providers/microsoft.operationalinsights/workspaces/*workspacename*'; cluster(CL1).database('*workspacename*').AuditLogs | where Category == "EntitlementManagement" and OperationName == "Fulfill access package assignment request" | mv-expand TargetResources | where TargetResources.type == 'AccessPackage' | project ActivityDateTime,APID = toguid(TargetResources.id) | join EntraAccessPackages on $left.APID == $right.Id | limit 100
从其他源引入数据
可以在 Azure 数据资源管理器 中创建其他表 ,以便从其他源引入数据。 如果数据位于 JSON 文件(类似于前面的示例)或 CSV 文件中,则可以在首次 从文件获取数据时创建表。 创建表后,还可以使用 LightIngest 从 JSON 或 CSV 文件 将数据引入 Azure 数据资源管理器 。
有关数据引入的更多信息,请参阅 Azure 数据资源管理器数据引入概述。
示例:将 Microsoft Entra 和另一个源中的应用分配进行组合,创建有权在两个日期之间访问某个应用程序的所有用户的报告
此报告说明了如何合并两个单独系统中的数据来在 Azure 数据资源管理器中创建自定义报告。 它将有关用户、其角色和其他属性的数据从两个系统聚合为统一格式进行分析或报告。
以下示例假定命名 salesforceAssignments
的表填充了来自另一个应用程序的数据。 该表包含列UserName
、Name
、EmployeeId
、Department
、JobTitle
、AppName
、Role
和CreatedDateTime
。
// Define the date range and service principal ID for the query
let startDate = datetime("2023-06-01");
let endDate = datetime("2024-03-13");
let servicePrincipalId = "<your service principal-id>";
// Pre-process AppRoleAssignments with specific filters and projections
let processedAppRoleAssignments = AppRoleAssignments
| where ResourceId == servicePrincipalId and todatetime(CreatedDateTime) between (startDate .. endDate)
| extend AppRoleId = tostring(AppRoleId)
| project PrincipalId, AppRoleId, CreatedDateTime, ResourceDisplayName; // Exclude DeletedDateTime and keep ResourceDisplayName
// Pre-process AppRoles to get RoleDisplayName for each role
let processedAppRoles = AppRoles
| mvexpand AppRoles
| project AppRoleId = tostring(AppRoles.Id), RoleDisplayName = tostring(AppRoles.DisplayName);
// Main query: Process EntraUsers by joining with processed role assignments and roles
EntraUsers
| join kind=inner processedAppRoleAssignments on $left.ObjectID == $right.PrincipalId // Join with role assignments
| join kind=inner processedAppRoles on $left.AppRoleId == $right.AppRoleId // Join with roles to get display names
// Summarize to get the latest record for each unique combination of user and role attributes
| summarize arg_max(AccountEnabled, *) by UserPrincipalName, DisplayName, tostring(EmployeeId), Department, JobTitle, ResourceDisplayName, RoleDisplayName, CreatedDateTime
// Final projection of relevant fields, including source indicator and report date
| project UserPrincipalName, DisplayName, EmployeeId=tostring(EmployeeId), Department, JobTitle, AccountEnabled=tostring(AccountEnabled), ResourceDisplayName, RoleDisplayName, CreatedDateTime, Source="EntraUsers", ReportDate = now()
// Union with processed salesforceAssignments to create a combined report
| union (
salesforceAssignments
// Project fields from salesforceAssignments to align with the EntraUsers data structure
| project UserPrincipalName = UserName, DisplayName = Name, EmployeeId = tostring(EmployeeId), Department, JobTitle, AccountEnabled = "N/A", ResourceDisplayName = AppName, RoleDisplayName = Role, CreatedDateTime, Source = "salesforceAssignments", ReportDate = now()
)