【问题标题】:Azure Automation - Unable to get AzRoleAssignementAzure 自动化 - 无法获取 AzRoleAssignement
【发布时间】:2020-09-28 10:22:42
【问题描述】:

为了自动化某些流程,我正在使用 Azure 自动化,并拥有 RunAsAccount 的所有者权限。

$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

有解决这个问题的办法吗?

【问题讨论】:

    标签: azure azure-powershell azure-automation azure-rbac


    【解决方案1】:

    您可能需要向 RunAsAccount 授予 Azure AD Graph 的应用程序权限 Directory.Read.All(不是 Microsoft Graph,不是 Delegated 权限)。默认情况下,RunAsAccount 没有 Azure AD 权限。

    您可以阅读Joy's answer了解更多详情。

    【讨论】:

      【解决方案2】:

      SignInName 选项中没有为名称提供角色分配时,会显示此错误。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-07-14
        • 2021-11-28
        • 2022-11-10
        • 2020-10-19
        • 2019-04-16
        • 1970-01-01
        • 2018-05-26
        • 1970-01-01
        相关资源
        最近更新 更多