如何为应用授予Kusto特定数据库的dataConnections/read权限?
解决方案:为托管标识授予Kusto数据库级数据连接读取权限
问题场景
需为托管标识授予Azure Kusto特定数据库的数据连接读取权限,但Azure门户仅支持集群级IAM授权(数据库无IAM入口),直接在集群授权不符合安全要求,应用报错如下:
The client 'id' with object id 'id' does not have authorization to perform action 'Microsoft.Kusto/clusters/databases/dataConnections/read' over scope '/subscriptions/subscription/resourceGroups/RG/providers/Microsoft.Kusto/clusters/cluster/databases/database-foo'
解决步骤
由于Azure门户未提供Kusto数据库级IAM管理入口,需通过Azure CLI或PowerShell完成数据库范围的权限分配,以下是具体操作:
方法1:使用Azure CLI
- 创建自定义角色(仅需执行一次,可重复分配给多个标识)
az role definition create --role-definition '{ "Name": "Kusto Database Data Connection Reader", "Description": "仅授予指定Kusto数据库的数据连接读取权限", "Actions": [ "Microsoft.Kusto/clusters/databases/dataConnections/read" ], "AssignableScopes": [ "/subscriptions/<你的订阅ID>" ] }'
- 将角色分配给托管标识(指定目标数据库范围)
az role assignment create \ --assignee <托管标识对象ID> \ --role "Kusto Database Data Connection Reader" \ --scope "/subscriptions/<订阅ID>/resourceGroups/<资源组名>/providers/Microsoft.Kusto/clusters/<集群名>/databases/<目标数据库名>"
方法2:使用PowerShell
- 创建自定义角色
$roleDefinition = @{ Name = "Kusto Database Data Connection Reader" Description = "仅授予指定Kusto数据库的数据连接读取权限" Actions = @("Microsoft.Kusto/clusters/databases/dataConnections/read") AssignableScopes = @("/subscriptions/<你的订阅ID>") } New-AzRoleDefinition -InputObject $roleDefinition
- 分配角色到目标数据库
New-AzRoleAssignment ` -ObjectId <托管标识对象ID> ` -RoleDefinitionName "Kusto Database Data Connection Reader" ` -Scope "/subscriptions/<订阅ID>/resourceGroups/<资源组名>/providers/Microsoft.Kusto/clusters/<集群名>/databases/<目标数据库名>"
注意事项
- 替换命令中所有
<>包裹的占位符为实际资源信息 - 执行命令的账号需具备角色定义创建和角色分配权限(如
Owner或User Access Administrator) - 权限生效可能需要5-10分钟的同步时间
内容的提问来源于stack exchange,提问作者Rajesh Patel
相关产品推荐
相关产品推荐

