简体   繁体   English

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

[英]Cannot login to Azure Powershell without an interactive prompt

I am trying to run a PowerShell script on a continuous integration build server to automatically deploy using Azure Powershell. 我正在尝试在持续集成生成服务器上运行PowerShell脚本,以使用Azure Powershell自动进行部署。

I cannot get around having to deal with a prompt that asks for credentials when trying to run the script. 在尝试运行脚本时,我无法避免遇到提示要求提供凭据的提示。

This is how I'm logging in: 这是我的登录方式:

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

And this is one of the commands which interactively prompts to enter a password even after I've already logged in: 这是即使我已经登录后也会交互提示输入密码的命令之一:

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

How can I avoid the prompt and use Azure Powershell for deploying on a build server? 如何避免出现提示并使用Azure Powershell在生成服务器上进行部署?

You can use a service principal to authenticate with Azure PowerShell without the need for an interactive prompt. 您可以使用服务主体通过Azure PowerShell进行身份验证,而无需交互式提示。 Creation of a service principal is documented here . 这里记录了服务主体的创建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM