Gallery › Compute › Azure built-in policies
Only approved VM extensions should be installed
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy governs the virtual machine extensions that are not approved.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONVirtualMachines_ApprovedExtensions_Audit.json · 57 lines
{
"properties": {
"displayName": "Only approved VM extensions should be installed",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy governs the virtual machine extensions that are not approved.",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"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"
}
},
"approvedExtensions": {
"type": "Array",
"metadata": {
"description": "The list of approved extension types that can be installed. Example: AzureDiskEncryption",
"displayName": "Approved extensions"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines/extensions"
},
{
"field": "Microsoft.Compute/virtualMachines/extensions/type",
"notIn": "[parameters('approvedExtensions')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c0e996f8-39cf-4af9-9f45-83fbde810432",
"name": "c0e996f8-39cf-4af9-9f45-83fbde810432"
}Bylawc0e996f8-39cf-4af9-9f45-83fbde810432.bylaw.ps1 · 34 lines
# Converted from VirtualMachines_ApprovedExtensions_Audit.json by ConvertTo-Bylaw.
Policy 'c0e996f8-39cf-4af9-9f45-83fbde810432' {
Properties @{
DisplayName = 'Only approved VM extensions should be installed'
Description = 'This policy governs the virtual machine extensions that are not approved.'
Version = '1.0.0'
Category = 'Compute'
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'
}
Parameter ApprovedExtensions @{
Type = 'Array'
DisplayName = 'Approved extensions'
Description = 'The list of approved extension types that can be installed. Example: AzureDiskEncryption'
}
Resource 'Microsoft.Compute/virtualMachines/extensions' {
Require 'type is one of the ApprovedExtensions parameter' {
Field 'Microsoft.Compute/virtualMachines/extensions/type' | Must -BeIn (Param ApprovedExtensions)
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Compute/VirtualMachines_ApprovedExtensions_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw