Gallery › Compute › Azure Community Policy
Audit VM BYOL Compliance
Converted Policy Audit Disabled Mode all Version 1.0.0
This policy audits whether an existing VM is enabled for OS BYOL or is based on a Linux GPL distro from Canonical, Debian or Rogue Wave (formerly OpenLogic).
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 65 lines
{
"name": "0932fbee-733b-4745-ae2d-f7ebf2b462b5",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit VM BYOL Compliance",
"description": "This policy audits whether an existing VM is enabled for OS BYOL or is based on a Linux GPL distro from Canonical, Debian or Rogue Wave (formerly OpenLogic).",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"mode": "all",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"in": [
"Microsoft.Compute/virtualMachines",
"Microsoft.Compute/VirtualMachineScaleSets"
]
},
{
"not": {
"anyOf": [
{
"field": "Microsoft.Compute/licenseType",
"equals": "Windows_Server"
},
{
"field": "Microsoft.Compute/imageOffer",
"contains": "byos"
},
{
"field": "Microsoft.Compute/imagePublisher",
"in": [
"Canonical",
"Debian",
"OpenLogic"
]
}
]
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw0932fbee-733b-4745-ae2d-f7ebf2b462b5.bylaw.ps1 · 35 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '0932fbee-733b-4745-ae2d-f7ebf2b462b5' {
Properties @{
DisplayName = 'Audit VM BYOL Compliance'
Description = 'This policy audits whether an existing VM is enabled for OS BYOL or is based on a Linux GPL distro from Canonical, Debian or Rogue Wave (formerly OpenLogic).'
Version = '1.0.0'
Category = 'Compute'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource * {
When {
Field type | Must -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.Compute/VirtualMachineScaleSets')
}
Require 'licenseType, imageOffer and imagePublisher are as required' {
AnyOf {
Field 'Microsoft.Compute/licenseType' | Must -Be 'Windows_Server'
Field 'Microsoft.Compute/imageOffer' | Must -ContainText 'byos'
Field 'Microsoft.Compute/imagePublisher' | Must -BeIn @('Canonical', 'Debian', 'OpenLogic')
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/audit-vm-byol-compliance/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw