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

使用Terraform创建带AAD认证的Azure VPN网关时遇参数不支持错误

解决Terraform创建Azure AAD认证VPN网关的参数错误问题

问题场景

使用Terraform Azurerm 2.99版本创建带AAD认证的Azure VPN网关时,执行计划报错,提示多个参数不被支持:

错误:不支持的参数
│ 
│   在main.tf的第834行,resource "azurerm_virtual_network_gateway" "vpn-gw"中:
│  834:     vpn_authentication_types = ["AAD"]
│ 
│ 此处不支持名为"vpn_authentication_types"的参数。
╵
╷
│ 错误:不支持的参数
│ 
│   在main.tf的第835行,resource "azurerm_virtual_network_gateway" "vpn-gw"中:
│  835:     tenant_uri = "https://login.microsoftonline.com/************************************"
│ 
│ 此处不支持名为"tenant_uri"的参数。
╵
╷
│ 错误:不支持的参数
│ 
│   在main.tf的第836行,resource "azurerm_virtual_network_gateway" "vpn-gw"中:
│  836:     audience_id = "41b23e61-6c1e-4545-b367-cd054e0ed4b4"
│ 
│ 此处不支持名为"audience_id"的参数。

问题原因

Azurerm 2.99版本中,AAD类型的VPN客户端认证配置有特定的嵌套块结构,且参数名称与当前使用的不匹配:

  1. AAD相关配置需通过aad_vpn_client_configuration嵌套块定义,而非直接放在vpn_client_configuration下
  2. 部分参数名称存在差异,且tenant_uri只需传入租户ID而非完整URL

修正后的代码

替换原配置中的vpn_client_configuration块为以下内容:

vpn_client_configuration {
  address_space = ["xx.xxx.xx/24"]
  authentication_types = ["AAD"]
  aad_vpn_client_configuration {
    tenant_id = "xxxxxxxxxxxxxxxxxxxxxxxxx"
    audience = "41b23e61-6c1e-4545-b367-cd054e0ed4b4"
    issuer = "https://sts.windows.net/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

修改说明

  • 将原vpn_authentication_types改为authentication_types,保留值["AAD"]
  • 新增aad_vpn_client_configuration嵌套块,集中存放AAD认证参数
  • 参数映射替换:
    • tenant_uri → tenant_id:仅需传入租户ID字符串(从原URL的路径部分提取)
    • audience_id → audience:直接使用原参数值
    • aad_issuer_uri → issuer:直接使用原参数值

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 06:54:23