Gallery › Compute › Azure Community Policy
Approved VM images
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy governs the approved VM images
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 54 lines
{
"name": "35c89f34-7393-412c-ad0b-cc0b9f2094ef",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Approved VM images",
"description": "This policy governs the approved VM images",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"mode": "All",
"parameters": {
"imageIds": {
"type": "array",
"metadata": {
"description": "The list of approved VM images. Example values: '/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage' or /Subscriptions/<subscriptionId>/Providers/Microsoft.Compute/Locations/centralus/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/2016.127.20180510'",
"displayName": "Approved VM images"
}
},
"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.Compute/virtualMachines"
},
{
"not": {
"field": "Microsoft.Compute/imageId",
"in": "[parameters('imageIds')]"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw35c89f34-7393-412c-ad0b-cc0b9f2094ef.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '35c89f34-7393-412c-ad0b-cc0b9f2094ef' {
Properties @{
DisplayName = 'Approved VM images'
Description = 'This policy governs the approved VM images'
Version = '1.0.0'
Category = 'Compute'
Mode = 'All'
}
Parameter ImageIds @{
Type = 'array'
DisplayName = 'Approved VM images'
Description = 'The list of approved VM images. Example values: ''/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'' or /Subscriptions/<subscriptionId>/Providers/Microsoft.Compute/Locations/centralus/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/2016.127.20180510'''
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Compute/virtualMachines' {
Require 'imageId is one of the ImageIds parameter' {
Field 'Microsoft.Compute/imageId' | Must -BeIn (Param ImageIds)
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/approved-vm-images/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw