Gallery › Compute › Azure Community Policy
Deny hybrid use benefit
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy will deny usage of hybrid use benefit.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 48 lines
{
"name": "edb76111-e0f0-4451-a840-eb63ad1e3df2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deny hybrid use benefit",
"description": "This policy will deny usage of hybrid use benefit.",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"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/virtualMachines",
"Microsoft.Compute/VirtualMachineScaleSets"
]
},
{
"field": "Microsoft.Compute/licenseType",
"equals": "Windows_Server"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawedb76111-e0f0-4451-a840-eb63ad1e3df2.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'edb76111-e0f0-4451-a840-eb63ad1e3df2' {
Properties @{
DisplayName = 'Deny hybrid use benefit'
Description = 'This policy will deny usage of hybrid use benefit.'
Version = '1.0.0'
Category = 'Compute'
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/virtualMachines', 'Microsoft.Compute/VirtualMachineScaleSets')
}
Require 'licenseType is not Windows_Server' {
Field 'Microsoft.Compute/licenseType' | Must -Not -Be 'Windows_Server' -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/deny-hybrid-use-benefit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw