使用 Kusto 查询 Azure 用户分配的托管身份
· 约 1 分钟阅读
在 Azure Portal 的用户分配托管身份资源列表中,可按名称、资源组、订阅等信息筛选,但无法直接通过 Client ID 搜索。借助 Azure Resource Graph 的 Kusto 查询功能,可以在所有订阅中按 Client ID 查询 UAI。
以下 Kusto 查询语句可用于 Azure Resource Graph Explorer 等工具,查询当前用户所有订阅中的 UAI。
查询单个 Client ID:
resources| where type == "microsoft.managedidentity/userassignedidentities"| where properties.clientId == "Your client id"| project name, resourceGroup, subscriptionId, id, location, properties.principalId查询多个 Client ID:
resources| where type == "microsoft.managedidentity/userassignedidentities"| where properties.clientId in ("Your client id 1", "Your client id 2")| project name, resourceGroup, subscriptionId, id, location, properties.principalId