You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行terraform init遇ARM配置构建错误,需存储tfstate至存储账户

解决Terraform初始化Azure后端时的CLI身份验证错误

问题场景

需要通过Terraform创建Azure资源组,并将terraform.tfstate远程存储到Azure存储账户中。配置好backend后执行terraform init命令时触发以下错误:

Error building ARM Config: Authenticating using the Azure CLI is only supported as a User (not a Service Principal)

移除backend相关配置后,Terraform可正常运行,说明问题出在backend配置的身份验证环节。

解决方案步骤

  • 创建Azure服务主体(可通过az ad sp create-for-rbac命令生成)
  • 使用服务主体身份登录Azure CLI,执行命令:
    az login --service-principal -u <client_id> -p <secret> --tenant <tenant_id>
    
    替换<client_id>、<secret>、<tenant_id>为你创建的服务主体对应信息
  • 重新执行terraform init,即可完成初始化并正常连接Azure存储账户作为backend

内容的提问来源于stack exchange,提问作者cekodis681

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 11:22:02