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

使用Terraform部署Azure OpenAI内容过滤器遇问题求助

问题原因

你遇到的错误是因为使用了Azure OpenAI控制台显示的友好名称,而Terraform的azurerm_cognitive_account_rai_policy资源要求使用官方定义的内部标识符来指定这些特殊过滤器类别。暴力、仇恨等基础类别名称和标识符一致,但你提到的这几个高级过滤器有不同的内部命名规则。

解决方案

将content_filter块中的name字段替换为以下对应内部标识符:

  • Prompt shields for jailbreak attacks → Jailbreak
  • Prompt shields for indirect attacks → IndirectAttack
  • Protected material for text → TextProtectedMaterial
  • Protected material for code → CodeProtectedMaterial

修正后的Terraform配置示例:

resource "azurerm_cognitive_account_rai_policy" "policy" {
  name                  = "example-policy"
  cognitive_account_id  = azurerm_cognitive_account.account.id
  base_policy_name      = "Microsoft.DefaultV2"

  content_filter {
    name               = "Jailbreak"
    filter_enabled     = true
    block_enabled      = true
    source             = "Prompt"
  }

  # 可添加其他高级过滤器示例
  content_filter {
    name               = "IndirectAttack"
    filter_enabled     = true
    block_enabled      = true
    source             = "Prompt"
  }

  depends_on = [azurerm_cognitive_account.account]
}
额外注意事项
  1. 确保你使用的AzureRM Terraform Provider版本是3.0以上,旧版本可能不支持这些高级RAI过滤器的配置。可以通过terraform init -upgrade命令升级Provider。
  2. 部分高级过滤器可能需要你的Azure OpenAI账户启用对应功能,如果替换标识符后仍报错,检查账户是否有相关权限或功能开启。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 15:42:01