Gallery › SQL › Azure Community Policy
Require SQL Server VM Auto Patching
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Require SQL Server Virtual Machines to have Auto Patching enabled/disabled
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 53 lines
{
"name": "b91cdf09-d6fb-4150-afa9-d2a9ab7854d1",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Require SQL Server VM Auto Patching",
"description": "Require SQL Server Virtual Machines to have Auto Patching enabled/disabled",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"autoPatchingSetting": {
"type": "Boolean",
"metadata": {
"displayName": "Auto Patching Setting",
"description": "A boolean value for whether or not Auto Patching needs to be enabled on a SQL Server VM."
},
"defaultValue": true
},
"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",
"equals": "Microsoft.SqlVirtualMachine/sqlVirtualMachines"
},
{
"field": "Microsoft.SqlVirtualMachine/sqlVirtualMachines/autoPatchingSettings.enable",
"equals": "[parameters('autoPatchingSetting')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawb91cdf09-d6fb-4150-afa9-d2a9ab7854d1.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'b91cdf09-d6fb-4150-afa9-d2a9ab7854d1' {
Properties @{
DisplayName = 'Require SQL Server VM Auto Patching'
Description = 'Require SQL Server Virtual Machines to have Auto Patching enabled/disabled'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter AutoPatchingSetting @{
Type = 'Boolean'
Default = $true
DisplayName = 'Auto Patching Setting'
Description = 'A boolean value for whether or not Auto Patching needs to be enabled on a SQL Server VM.'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.SqlVirtualMachine/sqlVirtualMachines' {
Require 'autoPatchingSettings.enable is not the AutoPatchingSetting parameter' {
Field autoPatchingSettings.enable | Must -Not -Be (Param AutoPatchingSetting) -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/SQL/require-sql-server-vm-auto-patching/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw