Azure OpenAI Content Filtering with Terraform - Deployment Issues

I’m working on setting up Azure OpenAI using Terraform and running into some problems with content filtering. The basic setup with azurerm_cognitive_account and azurerm_cognitive_deployment worked fine, but I’m having trouble with certain filter types when using azurerm_cognitive_account_rai_policy.

The standard filters like Violence, Hate, Sexual, and Self-harm work without issues. However, I keep getting errors when trying to set up advanced protection filters like Jailbreak prompt protection, Indirect attack shields, Text material protection, and Code material safeguards.

Here’s my configuration:

resource "azurerm_cognitive_account_rai_policy" "content_policy" {
  name                  = "my-content-policy"
  cognitive_account_id  = azurerm_cognitive_account.openai_service.id
  base_policy_name      = "Microsoft.DefaultV2"

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

  depends_on = [azurerm_cognitive_account.openai_service]
}

The error message I’m seeing:

Error: creating Rai Policy: unexpected status 400 (400 Bad Request) with error: Resource has invalid content filter: The content filter Jailbreak prompt protection in the policy is not supported.

Any ideas why these specific filter types aren’t working? Are there different naming conventions or additional requirements for these advanced filters?

This happens because Terraform’s azurerm provider uses different names than what you see in the Azure API. For those advanced protection filters, use: jailbreak instead of “Jailbreak prompt protection”, protected_material_text for “Text material protection”, and protected_material_code for “Code material safeguards”. I ran into the same thing with content policies - the docs don’t make these naming differences clear at all. Also double-check that your Azure OpenAI resource location actually supports these filters since they’re not available everywhere.