Gallery › Cognitive Services › Azure built-in policies
Cognitive Services accounts should use a managed identity
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
Assigning a managed identity to your Cognitive Service account helps ensure secure authentication. This identity is used by this Cognitive service account to communicate with other Azure services, like Azure Key Vault, in a secure way without you having to manage any credentials.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONManagedIdentity_Audit.json · 58 lines
{
"properties": {
"displayName": "Cognitive Services accounts should use a managed identity",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Assigning a managed identity to your Cognitive Service account helps ensure secure authentication. This identity is used by this Cognitive service account to communicate with other Azure services, like Azure Key Vault, in a secure way without you having to manage any credentials.",
"metadata": {
"version": "1.0.0",
"category": "Cognitive Services"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "Audit",
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "The effect determines what happens when the policy rule is evaluated to match"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.CognitiveServices/accounts"
},
{
"anyOf": [
{
"field": "identity.type",
"exists": "false"
},
{
"field": "identity.type",
"equals": "None"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/fe3fd216-4f83-4fc1-8984-2bbec80a3418",
"name": "fe3fd216-4f83-4fc1-8984-2bbec80a3418"
}Bylawfe3fd216-4f83-4fc1-8984-2bbec80a3418.bylaw.ps1 · 33 lines
# Converted from ManagedIdentity_Audit.json by ConvertTo-Bylaw.
Policy 'fe3fd216-4f83-4fc1-8984-2bbec80a3418' {
Properties @{
DisplayName = 'Cognitive Services accounts should use a managed identity'
Description = 'Assigning a managed identity to your Cognitive Service account helps ensure secure authentication. This identity is used by this Cognitive service account to communicate with other Azure services, like Azure Key Vault, in a secure way without you having to manage any credentials.'
Version = '1.0.0'
Category = 'Cognitive Services'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'The effect determines what happens when the policy rule is evaluated to match'
}
Resource 'Microsoft.CognitiveServices/accounts' {
Require 'identity.type exists' {
Field identity.type | Must -Exist
}
Require 'identity.type is not None' {
Field identity.type | Must -Not -Be 'None' -IfPresent
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Cognitive Services/ManagedIdentity_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw