azure - 尝试从 VS Code 运行 Terraform Plan 时出错
问题描述
我正在尝试从 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 时仍然出现错误的任何原因
解决方案
正如评论中所讨论的:
您需要使用 Azure CLI 并az login
首先运行。引擎盖下的 Terraform 并未使用 Az-Powershell。
推荐阅读
- php - 加载更多按钮在 Wordpress 上不起作用
- java - 使用“com.mongodb.util.JSONParseException”传输 BSON 文件时出错
- git - 将 git repo 的一部分作为子模块添加到另一部分
- php - 如何修复 OneSignal 推送通知返回“所有包含的玩家未订阅”?
- reactjs - 如何知道以 react-scripts start 启动的应用程序是在开发模式或生产模式下启动的
- vba - MS Access 表单无法在其他计算机上打开
- postman - 为什么邮递员要复制自己?
- r - 来自 install_github() 的 ggbipolt:库(ggbiplot)不加载
- qt3d - Qt3DWindow 中的双缓冲
- c++ - 计算 ns3 中的数据包接收时间