为什么我在为 runbook 创建 webhook 时收到授权失败异常?

Why am I getting an authorization failed exception for creating a webhook for a runbook?

我正在尝试为我创建的 Runbook 创建 Webhook。在UI中,"New Webhook"按钮是灰色的,无法选择。当我尝试 New-AzureRmAutomationWebhook powershell 命令时,它失败并出现以下异常:

New-AzureRmAutomationWebhook : AuthorizationFailed: The client '*****' with object id '******-****-****-****-**********' does not have authorization to perform action 'Microsoft.Automation/automationAccounts/webhooks/action' over scope '/subscriptions/*****/resourceGroups/*******/providers/Microsoft.Automation/automationAccounts/********/webhooks/generateUri' where asterisks are my account specific information.

我所在的组是 Runbook 和自动化帐户所在的资源组的所有者。我可能会看到此错误的原因有哪些?我该如何补救?

谢谢!

如果我理解正确,您能够成功创建 RunBook,但是当您尝试为 Runbook 创建 webhook 时收到上述 authZ 异常?这看起来确实像是一个 RBAC 问题,所以我建议您首先检查您在自动化帐户上的 RBAC 分配。您可以通过 Azure Portal or PowerShell using Get-AzureRmRoleAssignment
查看分配给您的角色 确保您在托管自动化帐户的资源组中具有 "Owner" 角色。我可以确认资源组中的 "owner" 角色是创建 webhook 别名所需的全部。该按钮显示为灰色的事实表明您可能缺少导致失败的必需角色分配。还要检查您的订阅(或资源组)是否有任何 Azure 管理策略阻止创建 webhook 资源。如果 Runbook 处于草稿模式且尚未发布,则按钮可能会变灰的唯一其他方式是,因为您只能为已发布的 Runbook 创建 Webhook。也就是说,您将收到的错误将明确指出没有与运行手册关联的已发布版本,这在您的场景中似乎并非如此。 以下是一些可能有用的资源: 1. managing RBAC assignments for Azure Automation 2.Starting an Azure Automation Runbook with a Webhook