azure - Azure 自动化 - 无法获取 AzRoleAssignement
问题描述
为了使某些流程自动化,我正在使用具有 RunAsAccount 所有者权限的Azure 自动化。
$connection = Get-AutomationConnection -Name AzureRunAsConnection
while(!($connectionResult) -And ($logonAttempt -le 10))
{
$LogonAttempt++
# Logging in to Azure...
$connectionResult = Connect-AzAccount `
-ServicePrincipal `
-Tenant $connection.TenantID `
-ApplicationId $connection.ApplicationID `
-CertificateThumbprint $connection.CertificateThumbprint
Start-Sleep -Seconds 30
Write-Output $connectionResult
}
Get-AzRoleAssignment -ResourceGroupName $USERRGNAME -SignInName $USEREMAIL -verbos
每次执行脚本时都会引发错误:
Get-AzRoleAssignment: Cannot find principal using the specified options
有什么想法可以解决这个问题吗?
解决方案
可能您需要为RunAsAccount提供 Azure AD Graph 的应用程序权限Directory.Read.All
(不是 Microsoft Graph,不是委派权限)。默认情况下,RunAsAccount没有 Azure AD 权限。
您可以阅读乔伊的答案以获取更多详细信息。
推荐阅读
- python-3.x - cv2.VideoWriter() 似乎没有使用“H264”编解码器输出任何内容,非常适合“mp4v”
- flutter - Flutter 更新后,GraphQL 和 JSON 序列化停止正常工作
- ios - SPM 无法解决具有特定 Internet 连接的包图
- python - 改变线型圆段维恩图
- windows - 在 Windows 11 中无法识别“g++”
- javascript - 关于缩放事件的传单过滤器数据
- node.js - Mongodb Node.js 从函数中获取查询结果
- curl - 如何在 yml 中运行 curl 请求
- angular - Angular 5表单提交标志未定义
- elasticsearch - 弹性搜索的所有分片未更新