Azure Devops 无权执行操作 Microsoft.Authorization/roleAssignments/write

joh*_*ley 9 azure azure-devops

我正在尝试自动设置从 Azure DevOps 执行的 letEncrypt 所需的服务主体。我正在运行以下代码

Write-Host ("Getting roles for " + $letsEncryptApplication.ApplicationId)
$letsEncryptContributorRole = Get-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $letsEncryptApplication.ApplicationId
if ($letsEncryptContributorRole -eq $null) {
    Write-Host "Creating contributor role for lets encrypt service principal"
    $letsEncryptContributorRole = New-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $letsEncryptApplication.ApplicationId
} else {
    Write-Host "Contributor role for lets encrypt service principal already exists"
}
Run Code Online (Sandbox Code Playgroud)

我在 New-AzureRmRoleAssignment 行上收到以下错误

does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/15ed030e-195f-4fc0-bbb9-cfcf581a1c00'.
Run Code Online (Sandbox Code Playgroud)

我已经通过 Azure DevOps 服务主体的应用程序注册执行此代码,并将我认为与活动目录相关的所有内容都给了它:

  • 读取和写入所有应用程序
  • 管理此应用创建或拥有的应用
  • 读写目录数据
  • 阅读所有用户的基本资料
  • 阅读所有用户的完整资料

我需要授予我的 Azure DevOps 服务主体什么权限才能自动执行这部分部署?