无法在Azure Devops上运行的Powershell脚本中访问Azure Key保管库密钥

时间:2019-03-26 22:28:27

标签: azure powershell azure-devops azure-resource-manager azure-keyvault

我有一个Powershell脚本,尝试使用此命令检索存储在Azure密钥库中的机密。

$password = (Get-AzureKeyVaultSecret -vaultName $vaultName -name $secretName).SecretValueText

当我在本地执行我的powershell脚本时,它的运行情况非常好。但是,当我尝试在Azure Devops上执行相同操作时,它无法给出以下错误。

[error]Operation returned an invalid status code 'Forbidden'

我认为这不是访问策略问题,因为我能够使用本地运行的powershell脚本成功对我的保管库执行读/写操作。

1 个答案:

答案 0 :(得分:2)

我很确定这是一个访问策略问题。

转到“ DevOps项目设置-管道-服务连接”,然后单击“更新服务连接”(使用对话框的完整版本)。您可以在其中找到订阅ID和服务主体ID。

然后,您必须对此SPN赋予明确的权限:

// App.js

import React from 'react';

const App = () => {
  const recipes = [{
    recipe_id: '<id>',
    image_url: '<some url>',
    title: 'Lé title'
  }];

  // recipes could be null/undefined or not even passed as a prop

  return (
    <Recipes recipes={recipes} />
  );
}
export default App;
相关问题