gpt4 book ai didi

azure - 使用 Azure 服务主体创建 Azure 资源时权限不足,无法完成操作

转载 作者:行者123 更新时间:2023-12-02 07:12:56 26 4
gpt4 key购买 nike

我想使用服务主体帐户来运行创建 Azure 资源的 Powershell 脚本,如 this article about doing so when provisioning via TeamCity 中的建议。

我能够创建服务主体并为其分配订阅的“所有者”角色,因此理论上它应该有权在 Azure 帐户中执行任何操作。 (稍后我会将权限调整为主体所需的权限。)命令基本上如下:

Login-AzureRmAccount # using my Azure admin account
$azureAdApplication = New-AzureRmADApplication -DisplayName "Deploy" -HomePage "https://deploy" -IdentifierUris "https://deploy" -Password "password"
New-AzureRmADServicePrincipal -ApplicationId $azureAdApplication.ApplicationId
New-AzureRmRoleAssignment -RoleDefinitionName Owner -ServicePrincipalName $azureAdApplication.ApplicationId
$subscription = Get-AzureRmSubscription
$creds = Get-Credential
Login-AzureRmAccount -Credential $creds -ServicePrincipal -Tenant $subscription.TenantId

但是,当我运行配置资源的 Powershell 脚本时,在创建 Key Vault 时收到以下警告:

  • 权限不足,无法完成操作
  • 未设置访问策略。没有用户或应用程序具有使用此保管库的访问权限。请使用Set-AzureRmKeyVaultAccessPolicy设置访问策略

通过我自己的管理员帐户创建 Key Vault 时,我没有收到这些警告。如何为服务主体授予足够的权限,以便能够在 Azure 订阅中创建资源而不会出现权限问题?

最佳答案

这是因为您创建了服务主体而不是用户,并且正在尝试与 Azure Vault 进行交互。 (其他一切都应该按预期工作)

作为用户,您可以访问 Vault,但由于您是作为服务主体访问它,因此它期望找到相关的访问策略。

关于azure - 使用 Azure 服务主体创建 Azure 资源时权限不足,无法完成操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35322745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com