我有一个 VSTS 使用的服务主体来运行 Azure Powershell 脚本。我试图调用的命令是Get-AzureRmRoleAssignment
。我收到以下错误消息
"Exception": {
"Request": {
"Method": "POST",
"RequestUri": "https://graph.windows.net/********/getObjectsByObjectIds?api-version=1.6",
"Properties": "System.Collections.Generic.Dictionary`2[System.String,System.Object]",
"Headers": "System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.IEnumerable`1[System.String]]"
},
"Response": {
"StatusCode": 403,
"ReasonPhrase": "Forbidden",
"Content": {
"odata.error": {
"code": "Authorization_RequestDenied",
"message": {
"lang": "en",
"value": "Insufficient privileges to complete the operation."
}
}
},
"Headers": "System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.IEnumerable`1[System.String]]"
}
}
我已验证服务主体具有角色分配的读取访问权限。
实际上,这个powershell脚本Get-AzureRmRoleAssignment
不仅需要具有 Azure REST API 权限的角色分配的读取访问权限但也需要使用 Azure AD Graph API 读取目录数据权限.
我们可以使用 Fiddler 来找出该命令调用了哪个 API:
代表着Get-AzureRmRoleAssignment
需要调用3个API来完成操作。其中两个是 Azure REST API,其中之一是 Azure AD Graph API:
POST https://graph.windows.net/<tenantID>/getObjectsByObjectIds?api-version=1.6
解决方案:
So, check if your sp has permissions to read directory data permission.(You'd better add Read directory data
permission both Application permissions and Delegated permissions and then click Grant permissions button). Here is my test result:
希望这可以帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)