You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Kusto查询获取租户tenantId对应的displayName

解决Azure Resource Graph中TenantId映射租户DisplayName的问题

方法1:通过TenantResources表关联查询

Azure Resource Graph的TenantResources表存储了租户级别的资源数据,其中microsoft.aadiam/directorytenants类型的记录包含租户的displayName和tenantId。你可以通过关联查询实现两者的映射:

Resources
| where type == "microsoft.network/virtualnetworks"
| project tenantId, id, name
| join kind=leftouter (
    TenantResources
    | where type == "microsoft.aadiam/directorytenants"
    | project tenantId, displayName = properties.displayName
) on tenantId

方法2:手动创建租户映射表

如果你的租户数量固定,可直接在查询中定义映射关系,适合小规模场景:

let tenantMap = datatable(tenantId:string, displayName:string) [
    "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "租户A",
    "yyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "租户B"
];
Resources
| where type == "microsoft.network/virtualnetworks"
| project tenantId, id, name
| join kind=leftouter tenantMap on tenantId

注意事项

  • 访问TenantResources表需要对应的租户级别读取权限,跨Lighthouse租户场景下需确保目标租户已授权该权限。
  • 若TenantResources表无法获取部分租户的displayName,说明该租户未开放租户级数据访问权限,此时只能通过Azure AD门户、PowerShell脚本导出租户列表等外部渠道获取信息后导入映射。

内容的提问来源于stack exchange,提问作者JoakimE

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 15:23:10