【发布时间】:2021-05-10 00:47:23
【问题描述】:
我正在尝试从 VS Code 登录到 Azure,以便我可以运行 Terraform 脚本。 所以我按照以下命令创建了一个 SP。
$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)
Add-AzAccount -Credential $psCred -TenantId $azureTenantId -ServicePrincipal `enter code here`
运行 Add-AzAccount 后,它会显示帐户名称、订阅名称、租户 ID 和环境。
但是当我现在尝试从我的 VS Code 运行 terraform plan 以便我可以检查将在我的 azure 环境中部署的所有内容时,它会在下面抛出这个错误:
Error: Error building account: Error getting authenticated object ID: Error parsing json result from
the Azure CLI: Error waiting for the Azure CLI: exit status 1: AADSTS50076: Due to a configuration
change made by your administrator, or because you moved to a new location, you must use multi-factor
authentication to access '00000002-0000-0000-c000-000000000000'.
Trace ID: 19a89f14-0138-4fbd-8d67-5f30c95e5701
Correlation ID: 7d80e2b1-49cc-4f42-9010-401e4453d13e
Timestamp: 2021-02-05 16:39:03Z
我也尝试通过键入 Login-AzAccount 登录并使用 Multi Factor Auth 登录,但我仍然看到上述错误。 即使我从 VS Code 登录到 Azure,在尝试运行 Terraform Plan 时仍然出现错误的任何原因
【问题讨论】:
-
在使用 Terraform 时,我实际上从未尝试使用 Az-Powershell 登录。您可以尝试使用 az CLI
az login吗? -
是的,我尝试使用 azcli 并有所帮助。有人告诉我,Terraform 似乎还不支持 Powershell 登录
标签: azure powershell terraform