错误 Get-AzureKeyVaultSecret: 无法检索 ServicePrincipal 帐户的服务密钥



使用 PowerShell,我可以在本地访问我的 Azure KeyVault,提供机密并返回存储的密码。我也可以从我启动的 VM 执行此操作。此外,我可以从 KeyVault 访问单个密码,并使用它来模拟 VSTS 生成代理上的用户,但我无法访问其余存储的密码。什么给?

这是我收到的消息:

[错误]Get-AzureKeyVaultSecret: 无法检索 的服务密钥 服务主体帐户 [隐藏帐户名称]@[公司帐户].com.请登录 再次提供此服务主体的凭据。在 PowerShell, execute Login-AzureRMAccount for Azure Resource Manager cmdlet 或 Add-AzureAccount for service management cmdlets。

  • CategoryInfo : CloseError: (:) [Get-AzureKeyVaultSecret], KeyNotFoundException
  • FullQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.GetAzureKeyVaultSecret

以下是我的代码在本节中的样子:

Login-AzureRmAccount -Credential $AzureCredential -ServicePrincipal -TenantId [abunchofnumbers]
$Password  = (Get-AzureKeyVaultSecret -VaultName "[nameOfVault]" -Name "[nameOfSecret]").SecretValueText

登录名接受提供的凭据并登录,但 Get-AzureKeyVaultSecret cmdlet 失败,并且仅在生成期间在 VSTS 上失败。

有什么想法吗,你们这些奇怪而出色的开发人员?

[已解决 - 跟进] 我的流程涉及一个Powershell脚本,通过使用Login-AzureRmAccount和Get-AzureKeyVaultSecret来模拟用户以获取用户的密码,然后是第二个Powershell脚本,用于重新登录到AzureRmAccount以从KeyVault获取更多密码。我交换了这两个脚本的顺序,问题消失了。

相关内容

最新更新