没有交互式提示,无法登录Azure Powershell

时间:2016-06-15 20:42:12

标签: powershell azure azure-powershell

我正在尝试在持续集成构建服务器上运行PowerShell脚本,以使用Azure Powershell自动部署。

我无法处理在尝试运行脚本时要求提供凭据的提示。

这就是我登录的方式:

$password = ConvertTo-SecureString "mypassword" -AsPlainText -Force
$cred = New-Object PSCredential("deployment@mysubscriptionname.onmicrosoft.com", $password)
Add-AzureRmAccount -Credential $cred

这是即使在我已经登录后以交互方式提示输入密码的命令之一:

Get-AzureKeyVaultSecret -VaultName my-vault-name -Name MySecret

如何避免提示并使用Azure Powershell在构建服务器上进行部署?

1 个答案:

答案 0 :(得分:3)

您可以使用服务主体对Azure PowerShell进行身份验证,而无需交互式提示。记录服务主体的创建here

相关问题