zhu*_*es3 1 azure azure-powershell
我需要使用 Powershell 来完成一些自动化的 Jenkins 工作。为了完成这项工作,我需要以非交互方式验证服务主体的身份。
通过 Azure CLI,可以使用以下命令以非交互方式完成此操作:
az login --service-principal -u "$client_id" -p "$client_secret" -t "$tenant_id"
Run Code Online (Sandbox Code Playgroud)
然而,Connect-AzAccount事实证明,使用 Powershell 的 cmdlet 来完成此任务非常困难。是否有办法使用 Powershell cmdlet 实现与上述相同的结果?这里描述的所有选项似乎都是交互式的。
任何帮助将不胜感激。
要使用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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4789 次 |
| 最近记录: |