我需要使用Powershell来执行一些自动化的Jenkins作业。要完成这项工作,我需要以非交互方式作为服务主体进行身份验证。
使用Azure CLI,可以使用以下命令以非交互方式完成此操作:
az login --service-principal -u "$client_id" -p "$client_secret" -t "$tenant_id"然而,事实证明,使用Powershell的Connect-AzAccount cmdlet很难做到这一点。有没有办法使用Powershell cmdlet实现与上面相同的结果?所有的选项described here似乎只是交互式的。
任何帮助都将不胜感激。
发布于 2019-04-09 08:55:54
要使用Connect-AzAccount以非交互方式登录,请尝试下面的命令,strong password是您的客户端机密,它在我这一端运行良好。
$azureAplicationId ="Azure AD Application Id"
$azureTenantId= "Your Tenant Id"
$azurePassword = ConvertTo-SecureString "strong password" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
Connect-AzAccount -Credential $psCred -TenantId $azureTenantId -ServicePrincipal

https://stackoverflow.com/questions/55582300
复制相似问题