使用适用于 Azure 服务总线的 IAM,如何为应用程序分配角色?

Using IAM for Azure Service Bus, how can I assign a role to an application?

背景

我想授予我的几个 Azure 服务总线队列的应用程序所有权...具体来说,通过授予它 Azure 服务总线数据所有者 角色。

Azure 服务总线文档说这是可能的:

Azure Service Bus supports using Azure Active Directory (Azure AD) to authorize requests to Service Bus entities (queues, topics, subscriptions, or filters). With Azure AD, you can use role-based access control (RBAC) to grant permissions to a security principal, which may be a user, group, or application service principal [my emphasis].

(Source)

但是,我找不到办法。

我试过的

  1. 已在 Azure AD 中注册应用程序。
  2. 已授予应用程序对 Microsoft.ServiceBususer_impersonation 权限。 (Application permissions 被禁用 [1],所以我选择了 Delegated permissions 并检查了 user_impersonation [2]。不知道是否正确。我刚才发布了 关于 Application permissions 被禁用,但编辑清单的公认答案在这种情况下不起作用。)
  3. 在我的服务总线队列中,选择 Role assignments
  4. 点击了 Add
  5. 搜索了我的申请。

问题

我的申请没有出现在 Role assignments 的搜索结果中。

服务主体是给定租户中应用程序的实例。 (Multi-tenant 应用程序可以在许多租户中拥有服务主体,所有租户都引用单个应用程序注册。)

要向应用程序授予 Azure 角色,服务主体必须首先存在于租户中。检查应用程序注册的服务主体是否已存在于注册该应用程序的同一租户中(如果不存在,则创建它):

使用 Azure 门户:

  1. 导航到 Azure AD > 应用注册 >(应用)> 概述
  2. 本地目录中的托管应用程序 标题下:
    • 如果您看到带有应用程序名称的 link,则服务主体已经存在。
    • 如果您看到 "Create service principal" link,单击它将尝试创建服务主体。

使用 Azure CLI:

az ad sp show --id {app-id}
az ad sp create --id {app-id}

使用 Azure AD PowerShell:

Get-AzureADServicePrincipal -Filter "appId eq '{app-id}'"
New-AzureADServicePrincipal -AppId "{app-id}"