代码之家  ›  专栏  ›  技术社区  ›  Mark Allison

如何从azure DevOps管道向azure密钥库写入机密?

  •  1
  • Mark Allison  · 技术社区  · 7 年前

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

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

    密钥库创建得很好,但在尝试写入机密时出现以下错误:

    [error]Access denied

    如果我跑了 Set-AzureKeyVaultSecret 在我的本地机器上工作正常。

    编辑

    下面是我所做的一些截图。在Azure DevOps中,我创建了一个服务连接并进行了验证:

    enter image description here

    以下是我的Azure PowerShell任务将秘密写入保险库的样子:

    enter image description here

    enter image description here

    enter image description here

    密钥保管库权限:

    enter image description here

    enter image description here

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

    2 回复  |  直到 7 年前
        1
  •  2
  •   4c74356b41    7 年前

    点击 Manage 中的链接 Azure Subscription 字段,它将引导您找到新刀片。点击 Manage Service Principal 在那里。它将带你到Azure广告中的应用程序页面。然后你可以在下面复制名称 Managed application in local directory 字段并使用该名称授予其密钥保管库权限。

    推荐文章