Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidTemplateDeployment - Resource has invalid blocklist reference - One or more of blocklists referenced in this policy are invalid #16343

Open
thomasninane opened this issue Feb 7, 2025 · 0 comments

Comments

@thomasninane
Copy link

Bicep version

Bicep CLI version 0.33.93 (7a77c7f)

Describe the bug

The following error Resource has invalid blocklist reference - One or more of blocklists referenced in this policy are invalid is thrown when trying to create an RAI Policy that uses an RAI Blocklist (the blocklist doesn't exist yes and is created via Bicep).

To Reproduce

Deploy this Bicep code:

// main.bicep
resource azureOpenAi 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
  name: '<AzureOpenAiResourceName>'
  location: 'swedencentral'
  identity: {
    type: 'SystemAssigned'
  }
  sku: {
    name: 'S0'
  }
  kind: 'OpenAI'
  properties: {
    publicNetworkAccess: 'Enabled'
    networkAcls: {
      defaultAction: 'Allow'
    }
    disableLocalAuth: false
    customSubDomainName: '<AzureOpenAiResourceName>'
  }
}

resource raiBlocklist 'Microsoft.CognitiveServices/accounts/raiBlocklists@2024-10-01' = {
  parent: azureOpenAi
  name: 'CustomBlocklist123'
  properties: {
    description: 'Custom blocklist for the Azure OpenAI resource'
  }
}

resource raiPolicy 'Microsoft.CognitiveServices/accounts/raiPolicies@2024-10-01' = {
  parent: azureOpenAi
  name: 'CustomContentFilter123'
  properties: {
    basePolicyName: 'Microsoft.DefaultV2'
    contentFilters: [
      {
        blocking: true
        enabled: true
        name: 'Violence'
        severityThreshold: 'High'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Violence'
        severityThreshold: 'High'
        source: 'Completion'
      }
      {
        blocking: true
        enabled: true
        name: 'Hate'
        severityThreshold: 'High'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Hate'
        severityThreshold: 'High'
        source: 'Completion'
      }
      {
        blocking: true
        enabled: true
        name: 'Sexual'
        severityThreshold: 'High'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Sexual'
        severityThreshold: 'High'
        source: 'Completion'
      }
      {
        blocking: true
        enabled: true
        name: 'Selfharm'
        severityThreshold: 'High'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Selfharm'
        severityThreshold: 'High'
        source: 'Completion'
      }
      {
        blocking: true
        enabled: true
        name: 'Jailbreak'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Indirect Attack'
        source: 'Prompt'
      }
      {
        blocking: true
        enabled: true
        name: 'Protected Material Text'
        source: 'Completion'
      }
      {
        blocking: true
        enabled: true
        name: 'Protected Material Code'
        source: 'Completion'
      }
    ]
    customBlocklists: [
      {
        blocking: true
        blocklistName: raiBlocklist.name
        source: 'Completion'
      }
    ]
    mode: 'Default'
  }
}

Additional context

It all works fine if I perform the deployment in 2 steps (which is not ideal):

  1. Comment these lines of code in the Bicep file above:
    customBlocklists: [
      {
        blocking: true
        blocklistName: raiBlocklist.name
        source: 'Completion'
      }
    ]
  1. Perform the deployment
  2. Un-comment the lines of code commented previously
  3. Perform the deployment again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant