Gallery › SQL Server › Azure Community Policy
Audit SQL VM BYOL Compliance
Converted Policy Audit Disabled Mode all Version 1.0.0
This policy audits whether an existing SQL Server VM is enabled for SQL Server BYOL.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 51 lines
{
"name": "29ed27e1-b63c-4ed3-af84-2d5c5c928024",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit SQL VM BYOL Compliance",
"description": "This policy audits whether an existing SQL Server VM is enabled for SQL Server BYOL.",
"metadata": {
"category": "SQL Server",
"version": "1.0.0"
},
"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",
"equals": "Microsoft.SqlVirtualMachine/sqlVirtualMachines"
},
{
"field": "Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlServerLicenseType",
"equals": "PAYG"
},
{
"field": "Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlImageSku",
"in": [
"Standard",
"Enterprise"
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw29ed27e1-b63c-4ed3-af84-2d5c5c928024.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '29ed27e1-b63c-4ed3-af84-2d5c5c928024' {
Properties @{
DisplayName = 'Audit SQL VM BYOL Compliance'
Description = 'This policy audits whether an existing SQL Server VM is enabled for SQL Server BYOL.'
Category = 'SQL Server'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.SqlVirtualMachine/sqlVirtualMachines' {
When {
Field sqlServerLicenseType | Must -Be 'PAYG'
}
Require 'sqlImageSku is not one of 2 values' {
Field sqlImageSku | Must -Not -BeIn @('Standard', 'Enterprise') -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/SQL Server/audit-sql-vm-byol-compliance/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw