Gallery › Compute › Azure Community Policy
allowed-vm-os
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
need to add description
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 117 lines
{
"name": "627ba003-4e9b-477d-b1f1-51bb08441b6e",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "allowed-vm-os",
"description": "need to add description",
"metadata": {
"category": "Compute",
"version": "1.0.0"
},
"mode": "All",
"parameters": {
"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",
"in": [
"Microsoft.Compute/disks",
"Microsoft.Compute/virtualMachines",
"Microsoft.Compute/VirtualMachineScaleSets"
]
},
{
"allOf": [
{
"not": {
"allOf": [
{
"field": "Microsoft.Compute/licenseType",
"notEquals": "Windows_Server"
},
{
"field": "Microsoft.Compute/imagePublisher",
"in": [
"MicrosoftWindowsServer"
]
},
{
"field": "Microsoft.Compute/imageOffer",
"in": [
"WindowsServer"
]
},
{
"field": "Microsoft.Compute/imageSku",
"in": [
"2016-Datacenter",
"2016-datacenter-gensecond",
"2016-Datacenter-Server-Core",
"2016-Datacenter-Server-Core-smalldisk",
"2016-Datacenter-smalldisk",
"2016-Datacenter-with-Containers",
"2016-Datacenter-with-RDSH",
"2016-Datacenter-zhcn"
]
}
]
}
},
{
"not": {
"allOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"in": [
"RedHat"
]
},
{
"field": "Microsoft.Compute/imageOffer",
"in": [
"RHEL"
]
},
{
"field": "Microsoft.Compute/imageSku",
"in": [
"7-LVM",
"7-RAW",
"7-RAW-CI",
"7.2",
"7.3",
"7.3-DAILY",
"7.4",
"7.5",
"7.6",
"7.7"
]
}
]
}
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw627ba003-4e9b-477d-b1f1-51bb08441b6e.bylaw.ps1 · 45 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '627ba003-4e9b-477d-b1f1-51bb08441b6e' {
Properties @{
DisplayName = 'allowed-vm-os'
Description = 'need to add description'
Category = 'Compute'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource * {
When {
Field type | Must -BeIn @('Microsoft.Compute/disks', 'Microsoft.Compute/virtualMachines', 'Microsoft.Compute/VirtualMachineScaleSets')
AnyOf {
Field 'Microsoft.Compute/licenseType' | Must -Be 'Windows_Server'
Field 'Microsoft.Compute/imagePublisher' | Must -Not -BeIn @('MicrosoftWindowsServer')
Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('WindowsServer')
Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('2016-Datacenter', '2016-datacenter-gensecond', '2016-Datacenter-Server-Core', '2016-Datacenter-Server-Core-smalldisk', '2016-Datacenter-smalldisk', '2016-Datacenter-with-Containers', '2016-Datacenter-with-RDSH', '2016-Datacenter-zhcn')
}
}
Require 'imagePublisher is one of 1 value' {
Field 'Microsoft.Compute/imagePublisher' | Must -BeIn @('RedHat')
}
Require 'imageOffer is one of 1 value' {
Field 'Microsoft.Compute/imageOffer' | Must -BeIn @('RHEL')
}
Require 'imageSku is one of 10 values' {
Field 'Microsoft.Compute/imageSku' | Must -BeIn @('7-LVM', '7-RAW', '7-RAW-CI', '7.2', '7.3', '7.3-DAILY', '7.4', '7.5', '7.6', '7.7')
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/allowed-vm-os/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw