Gallery › Security Center › Azure built-in policies
Configure Arc-enabled SQL Servers to automatically install Microsoft Defender for SQL
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.2.0
Configure Windows Arc-enabled SQL Servers to automatically install the Microsoft Defender for SQL agent. Microsoft Defender for SQL collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations).
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONMDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_Arc.json · 126 lines
{
"properties": {
"displayName": "Configure Arc-enabled SQL Servers to automatically install Microsoft Defender for SQL",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Configure Windows Arc-enabled SQL Servers to automatically install the Microsoft Defender for SQL agent. Microsoft Defender for SQL collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations).",
"version": "1.2.0",
"metadata": {
"category": "Security Center",
"version": "1.2.0"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "Windows"
},
{
"field": "Microsoft.HybridCompute/machines/mssqlDiscovered",
"equals": "true"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(field('Name'), '/MicrosoftDefenderForSQL')]",
"evaluationDelay": "AfterProvisioning",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.HybridCompute/machines/extensions/type",
"equals": "AdvancedThreatProtection.Windows"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/publisher",
"equals": "Microsoft.Azure.AzureDefenderForSQL"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
"in": [
"Succeeded",
"Provisioning succeeded"
]
}
]
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"location": {
"value": "[field('location')]"
},
"vmName": {
"value": "[field('Name')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"vmName": {
"type": "string"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(parameters('vmName'), '/', 'MicrosoftDefenderForSQL')]",
"apiVersion": "2022-11-10",
"location": "[parameters('location')]",
"tags": {
"createdBy": "MicrosoftDefenderForSQL"
},
"properties": {
"publisher": "Microsoft.Azure.AzureDefenderForSQL",
"type": "AdvancedThreatProtection.Windows",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true
}
}
]
}
}
}
}
}
},
"versions": [
"1.2.0",
"1.1.2",
"1.1.1-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/65503269-6a54-4553-8a28-0065a8e6d929",
"name": "65503269-6a54-4553-8a28-0065a8e6d929"
}Bylaw65503269-6a54-4553-8a28-0065a8e6d929.bylaw.ps1 · 42 lines
# Converted from MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_Arc.json by ConvertTo-Bylaw.
Policy '65503269-6a54-4553-8a28-0065a8e6d929' {
Properties @{
DisplayName = 'Configure Arc-enabled SQL Servers to automatically install Microsoft Defender for SQL'
Description = 'Configure Windows Arc-enabled SQL Servers to automatically install the Microsoft Defender for SQL agent. Microsoft Defender for SQL collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations).'
Category = 'Security Center'
Version = '1.2.0'
PolicyVersion = '1.2.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.HybridCompute/machines' {
When {
Field osName | Must -Be 'Windows'
}
Require 'mssqlDiscovered is not true' {
Field mssqlDiscovered | Must -Not -Be 'true' -IfPresent
}
}
DeployIfNotExists 'Microsoft.HybridCompute/machines/extensions' -Role 'Log Analytics Contributor' -Name (Arm '[concat(field(''Name''), ''/MicrosoftDefenderForSQL'')]') -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
Require 'type, publisher and provisioningState are as required' {
Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'AdvancedThreatProtection.Windows'
Field publisher | Must -Be 'Microsoft.Azure.AzureDefenderForSQL'
Field provisioningState | Must -BeIn @('Succeeded', 'Provisioning succeeded')
}
Deployment -TemplateFile './templates/65503269-6a54-4553-8a28-0065a8e6d929.json' -Parameters ([ordered]@{
location = (Arm '[field(''location'')]')
vmName = (Arm '[field(''Name'')]')
})
}
}Its deployment templates are written beside it:
templates/65503269-6a54-4553-8a28-0065a8e6d929.json
Source: built-in-policies/policyDefinitions/Security Center/MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_Arc.json in Azure/azure-policy, under the MIT licence.
Bylaw