azure - 如何从 Azure DevOps 管道将 secret 写入 azure key Vault?

标签 azure powershell azure-devops azure-keyvault

我已经使用 ARM 在 Azure DevOps 中创建了一个 Key Vault,现在我想在同一管道中向它写入一个 secret 。

我使用以下内联 PowerShell 创建了一个 Azure PowerShell 任务:

$secretvalue = ConvertTo-SecureString $(Secret) -AsPlainText -Force
Set-AzureKeyVaultSecret -VaultName $(VaultName) -Name $(SecretName) -SecretValue (ConvertTo-SecureString $(Secret) -AsPlainText -Force)

key 保管库创建得很好,但在尝试写入 key 时出现以下错误:

[错误]访问被拒绝

如果我在本地计算机上运行Set-AzureKeyVaultSecret,它就可以正常工作。

编辑

这是我所做的一些屏幕截图。在 Azure DevOps 中,我创建了一个服务连接并验证了它:

enter image description here

以下是将 secret 写入保管库的 Azure PowerShell 任务的样子:

enter image description here

enter image description here

enter image description here

key 保管库权限:

enter image description here

enter image description here

我需要单独的服务主体还是需要创建应用注册?

最佳答案

很确定您将权利授予了错误的实体。要找到正确的实体,请执行此操作。

单击Azure 订阅字段中的管理链接,它将导航到新 Blade 。单击此处的管理服务主体。它将带您进入 Azure AD 中的应用程序页面。之后,您可以在本地目录中的托管应用程序字段下复制名称,并使用该名称向其授予 Key Vault 权限。

关于azure - 如何从 Azure DevOps 管道将 secret 写入 azure key Vault?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52910591/

相关文章:

visual-studio-2012 - TF10175 : The team project does not exists

azure - 如何将 NPM 包推送到 Azure Artifact Feed?

android - 从 Windows Azure blob 下载图像?

azure - Azure Blob 存储 sftp 访问是否保证原子上传?

powershell - Azure 资源管理器虚拟机状态

arrays - PowerShell,Get-WinEvent -FilterHashTable ID 和数组的奇怪行为

tfs - TFS Build Online 2017 中 $(Build.Repository.LocalPath) 和 $(Build.SourcesDirectory) 的区别

azure - 如何从 azure 媒体播放器中删除加载图标

powershell - 显示磁盘大小和FreeSpace(以GB为单位)

powershell - 如何为Powershell函数的description属性添加值?