Gallery › Compute › Azure Community Policy
Prevent deployment of Windows VM or VMSS without BYOL
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
The policy checks if VMs or VM Scale Sets based on Microsoft operation system is using BYOL for Azure Hybrid Benefit. The decision, if VM is based on Microsoft OS or not, is based on the following policy:
[Preview]: Azure Security agent should be installed on your Windows virtual machines - Microsoft Azure
https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fbb2c6c6d-14bc-4443-bef3-c6be0adc6076
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"name": "4da7deca-a87a-4c88-9e39-a6249b1a0ca2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Prevent deployment of Windows VM or VMSS without BYOL",
"description": "The policy checks if VMs or VM Scale Sets based on Microsoft operation system is using BYOL for Azure Hybrid Benefit. The decision, if VM is based on Microsoft OS or not, is based on the following policy:\n[Preview]: Azure Security agent should be installed on your Windows virtual machines - Microsoft Azure\nhttps://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fbb2c6c6d-14bc-4443-bef3-c6be0adc6076",
"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/virtualMachineScaleSets",
"Microsoft.Compute/virtualMachines"
]
},
{
"anyOf": [
{
"field": "Microsoft.Compute/imagePublisher",
"contains": "Microsoft"
},
{
"field": "Microsoft.Compute/imagePublisher",
"contains": "Windows"
},
{
"field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
"contains": "Windows"
}
]
},
{
"anyOf": [
{
"field": "Microsoft.Compute/licenseType",
"exists": false
},
{
"not": {
"field": "Microsoft.Compute/licenseType",
"in": [
"Windows_Server",
"Windows_Client"
]
}
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '4da7deca-a87a-4c88-9e39-a6249b1a0ca2' {
Properties @{
DisplayName = 'Prevent deployment of Windows VM or VMSS without BYOL'
Description = 'The policy checks if VMs or VM Scale Sets based on Microsoft operation system is using BYOL for Azure Hybrid Benefit. The decision, if VM is based on Microsoft OS or not, is based on the following policy:
[Preview]: Azure Security agent should be installed on your Windows virtual machines - Microsoft Azure
https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fbb2c6c6d-14bc-4443-bef3-c6be0adc6076'
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/virtualMachineScaleSets', 'Microsoft.Compute/virtualMachines')
AnyOf {
Field 'Microsoft.Compute/imagePublisher' | Must -ContainText 'Microsoft'
Field 'Microsoft.Compute/imagePublisher' | Must -ContainText 'Windows'
Field 'Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType' | Must -ContainText 'Windows'
}
}
Require 'licenseType exists' {
Field 'Microsoft.Compute/licenseType' | Must -Exist
}
Require 'licenseType is one of 2 values' {
Field 'Microsoft.Compute/licenseType' | Must -BeIn @('Windows_Server', 'Windows_Client')
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/prevent-deployment-of-windows-vm-or-vmss-without-byol/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw