Gallery › Cognitive Services › Azure Community Policy
Permit only approved types of Cognitive Services
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy permits only certain types of Cognitive Services resources to be deployed.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 90 lines
{
"name": "976f4210-7bab-43c4-a3ac-45cebb0c4b12",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Permit only approved types of Cognitive Services",
"description": "This policy permits only certain types of Cognitive Services resources to be deployed.",
"metadata": {
"version": "1.0.0",
"category": "Cognitive Services"
},
"mode": "All",
"parameters": {
"listOfAllowedKind": {
"type": "Array",
"metadata": {
"description": "The list of Cognitive Services resources that can be deployed.",
"displayName": "Allowed Cognitive Services resources"
},
"allowedValues": [
"Academic",
"AnomalyDetector",
"Bing.Autosuggest",
"Bing.Autosuggest.v7",
"Bing.CustomSearch",
"Bing.Search",
"Bing.Search.v7",
"Bing.Speech",
"Bing.SpellCheck",
"Bing.SpellCheck.v7",
"CognitiveServices",
"ComputerVision",
"ContentModerator",
"CustomSpeech",
"CustomVision.Prediction",
"CustomVision.Training",
"Emotion",
"Face",
"FormRecognizer",
"ImmersiveReader",
"LUIS",
"LUIS.Authoring",
"MetricsAdvisor",
"OpenAI",
"Personalizer",
"QnAMaker",
"Recommendations",
"SpeakerRecognition",
"Speech",
"SpeechServices",
"SpeechTranslation",
"TextAnalytics",
"TextTranslation",
"WebLM"
]
},
"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"
},
{
"not": {
"field": "kind",
"in": "[parameters('listOfAllowedKind')]"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw976f4210-7bab-43c4-a3ac-45cebb0c4b12.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '976f4210-7bab-43c4-a3ac-45cebb0c4b12' {
Properties @{
DisplayName = 'Permit only approved types of Cognitive Services'
Description = 'This policy permits only certain types of Cognitive Services resources to be deployed.'
Version = '1.0.0'
Category = 'Cognitive Services'
Mode = 'All'
}
Parameter ListOfAllowedKind @{
Type = 'Array'
AllowedValues = @('Academic', 'AnomalyDetector', 'Bing.Autosuggest', 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck', 'Bing.SpellCheck.v7', 'CognitiveServices', 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', 'FormRecognizer', 'ImmersiveReader', 'LUIS', 'LUIS.Authoring', 'MetricsAdvisor', 'OpenAI', 'Personalizer', 'QnAMaker', 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechServices', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM')
DisplayName = 'Allowed Cognitive Services resources'
Description = 'The list of Cognitive Services resources 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' {
Require 'kind is one of the ListOfAllowedKind parameter' {
Field kind | Must -BeIn (Param ListOfAllowedKind)
}
}
Effect (Param Effect)
}Source: policyDefinitions/Cognitive Services/permit-only-approved-types-of-cognitive-services/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw