Gallery › Cognitive Services › Azure Community Policy
Permit only approved OpenAI models
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy permits only certain types of OpenAI models to be deployed
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 88 lines
{
"name": "d3eaceb3-3727-4260-a4ce-a968f69d70e5",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Permit only approved OpenAI models",
"description": "This policy permits only certain types of OpenAI models to be deployed",
"metadata": {
"version": "1.0.0",
"category": "Cognitive Services"
},
"mode": "All",
"parameters": {
"listOfAllowedModels": {
"type": "Array",
"metadata": {
"description": "The list of Open AI models that can be deployed.",
"displayName": "Allowed Open AI models"
},
"allowedValues": [
"gpt-4",
"gpt-4-32k",
"text-davinci-003",
"text-curie-001",
"code-davinci-002",
"code-cushman-001",
"text-similarity-ada-001",
"text-similarity-babbage-001",
"text-similarity-curie-001",
"text-similarity-davinci-001",
"text-search-ada-doc-001",
"text-search-ada-query-001",
"text-search-babbage-doc-001",
"text-search-babbage-query-001",
"text-search-curie-doc-001",
"text-search-curie-query-001",
"text-search-davinci-doc-001",
"text-search-davinci-query-001",
"code-search-ada-code-001",
"code-search-ada-text-001",
"code-search-babbage-code-001",
"code-search-babbage-text-001",
"gpt-35-turbo (version 0301)",
"text-ada-001",
"text-babbage-001",
"text-davinci-001",
"text-davinci-002",
"text-embedding-ada-002"
]
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.CognitiveServices/accounts/deployments"
},
{
"field": "Microsoft.CognitiveServices/accounts/deployments/model.format",
"equals": "OpenAI"
},
{
"not": {
"field": "Microsoft.CognitiveServices/accounts/deployments/model.name",
"in": "[parameters('listOfAllowedModels')]"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawd3eaceb3-3727-4260-a4ce-a968f69d70e5.bylaw.ps1 · 37 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'd3eaceb3-3727-4260-a4ce-a968f69d70e5' {
Properties @{
DisplayName = 'Permit only approved OpenAI models'
Description = 'This policy permits only certain types of OpenAI models to be deployed'
Version = '1.0.0'
Category = 'Cognitive Services'
Mode = 'All'
}
Parameter ListOfAllowedModels @{
Type = 'Array'
AllowedValues = @('gpt-4', 'gpt-4-32k', 'text-davinci-003', 'text-curie-001', 'code-davinci-002', 'code-cushman-001', 'text-similarity-ada-001', 'text-similarity-babbage-001', 'text-similarity-curie-001', 'text-similarity-davinci-001', 'text-search-ada-doc-001', 'text-search-ada-query-001', 'text-search-babbage-doc-001', 'text-search-babbage-query-001', 'text-search-curie-doc-001', 'text-search-curie-query-001', 'text-search-davinci-doc-001', 'text-search-davinci-query-001', 'code-search-ada-code-001', 'code-search-ada-text-001', 'code-search-babbage-code-001', 'code-search-babbage-text-001', 'gpt-35-turbo (version 0301)', 'text-ada-001', 'text-babbage-001', 'text-davinci-001', 'text-davinci-002', 'text-embedding-ada-002')
DisplayName = 'Allowed Open AI models'
Description = 'The list of Open AI models that can be deployed.'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.CognitiveServices/accounts/deployments' {
When {
Field model.format | Must -Be 'OpenAI'
}
Require 'model.name is one of the ListOfAllowedModels parameter' {
Field model.name | Must -BeIn (Param ListOfAllowedModels)
}
}
Effect (Param Effect)
}Source: policyDefinitions/Cognitive Services/permit-only-approved-openai-models/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw