如何使用 Terraform 在 Azure 中创建多租户服务主体
How to create a multi-tenant Service Principal in Azure using Terraform
我在一个租户中有一个服务主体需要访问另一个租户中的 Azure 容器注册表。但是,我不确定如何为此创建 azurerm_role_assignment。有没有办法将服务主体配置为多租户,以便它可以相应地在两个租户中分配角色?
首先在 terraform 中为 azure ad 应用程序和服务主体设置available_to_other_tenants = true
。
既然服务主体存在于您的租户中,将服务主体创建到另一个租户中的最快方法是使用 admin consent。
https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}
将{tenant-id}
替换为“另一个租户”的真实租户ID。 {client-id}
是 Azure 广告应用或服务主体的应用程序 ID。
在浏览器中访问 url。使用“另一个租户”的管理员帐户登录以接受权限。然后将在“另一个租户”中创建服务主体。
现在您可以为在“另一个租户”中创建的新服务主体(它是与原始服务主体不同的服务主体,它是多租户应用程序的工作方式)创建 azurerm_role_assignemnt
。
我在一个租户中有一个服务主体需要访问另一个租户中的 Azure 容器注册表。但是,我不确定如何为此创建 azurerm_role_assignment。有没有办法将服务主体配置为多租户,以便它可以相应地在两个租户中分配角色?
首先在 terraform 中为 azure ad 应用程序和服务主体设置available_to_other_tenants = true
。
既然服务主体存在于您的租户中,将服务主体创建到另一个租户中的最快方法是使用 admin consent。
https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}
将{tenant-id}
替换为“另一个租户”的真实租户ID。 {client-id}
是 Azure 广告应用或服务主体的应用程序 ID。
在浏览器中访问 url。使用“另一个租户”的管理员帐户登录以接受权限。然后将在“另一个租户”中创建服务主体。
现在您可以为在“另一个租户”中创建的新服务主体(它是与原始服务主体不同的服务主体,它是多租户应用程序的工作方式)创建 azurerm_role_assignemnt
。