Gallery › Security Center › Azure built-in policies
Configure Arc-enabled SQL Servers with Data Collection Rule Association to Microsoft Defender for SQL user-defined DCR
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.3.0
Configure association between Arc-enabled SQL Servers and the Microsoft Defender for SQL user-defined DCR. Deleting this association will break the detection of security vulnerabilities for this Arc-enabled SQL Servers.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONMDC_DfSQL_AMA_UserWorkspacePipeline_DCRA_Arc.json · 206 lines
{
"properties": {
"displayName": "Configure Arc-enabled SQL Servers with Data Collection Rule Association to Microsoft Defender for SQL user-defined DCR",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Configure association between Arc-enabled SQL Servers and the Microsoft Defender for SQL user-defined DCR. Deleting this association will break the detection of security vulnerabilities for this Arc-enabled SQL Servers.",
"version": "1.3.0",
"metadata": {
"category": "Security Center",
"version": "1.3.0"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"workspaceRegion": {
"type": "String",
"metadata": {
"displayName": "Workspace region",
"description": "Region of the Log Analytics workspace destination for the Data Collection Rule.",
"strongType": "location"
}
},
"userWorkspaceId": {
"type": "String",
"metadata": {
"displayName": "Workspace Id",
"description": "Workspace Id of the Log Analytics workspace destination for the Data Collection Rule."
},
"defaultValue": ""
},
"bringYourOwnDcr": {
"type": "Boolean",
"metadata": {
"displayName": "Bring your own DCR",
"description": "Enable or disable the use of a user-defined Data Collection Rule."
},
"allowedValues": [
true,
false
],
"defaultValue": false
},
"dcrResourceId": {
"type": "String",
"metadata": {
"displayName": "DCR Resource Id",
"description": "Resource Id of the user-defined Data Collection Rule."
},
"defaultValue": ""
}
},
"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.Insights/dataCollectionRuleAssociations",
"name": "MicrosoftDefenderForSQL-RulesAssociation",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/749f88d5-cbae-40b8-bcfc-e573ddc772fa",
"/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"resourceGroup": {
"value": "[resourceGroup().name]"
},
"vmName": {
"value": "[field('name')]"
},
"workspaceRegion": {
"value": "[parameters('workspaceRegion')]"
},
"userWorkspaceId": {
"value": "[parameters('userWorkspaceId')]"
},
"bringYourOwnDcr": {
"value": "[parameters('bringYourOwnDcr')]"
},
"dcrResourceId": {
"value": "[parameters('dcrResourceId')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroup": {
"type": "string"
},
"vmName": {
"type": "string"
},
"workspaceRegion": {
"type": "string"
},
"userWorkspaceId": {
"type": "string"
},
"bringYourOwnDcr": {
"type": "bool"
},
"dcrResourceId": {
"type": "string"
}
},
"variables": {
"locationLongNameToShortMap": {
"australiacentral": "CAU",
"australiaeast": "EAU",
"australiasoutheast": "SEAU",
"brazilsouth": "CQ",
"canadacentral": "CCA",
"canadaeast": "CCA",
"centralindia": "CIN",
"centralus": "CUS",
"eastasia": "EA",
"eastus2euap": "eus2p",
"eastus": "EUS",
"eastus2": "EUS2",
"francecentral": "PAR",
"germanywestcentral": "DEWC",
"japaneast": "EJP",
"jioindiawest": "CIN",
"koreacentral": "SE",
"koreasouth": "SE",
"northcentralus": "NCUS",
"northeurope": "NEU",
"norwayeast": "NOE",
"southafricanorth": "JNB",
"southcentralus": "SCUS",
"southeastasia": "SEA",
"southindia": "CIN",
"swedencentral": "SEC",
"switzerlandnorth": "CHN",
"switzerlandwest": "CHW",
"uaenorth": "DXB",
"uksouth": "SUK",
"ukwest": "WUK",
"westcentralus": "WCUS",
"westeurope": "WEU",
"westindia": "CIN",
"westus": "WUS",
"westus2": "WUS2"
},
"locationCode": "[if(contains(variables('locationLongNameToShortMap'), parameters('workspaceRegion')), variables('locationLongNameToShortMap')[parameters('workspaceRegion')], parameters('workspaceRegion'))]",
"subscriptionId": "[subscription().subscriptionId]",
"defaultRGName": "[concat('DefaultResourceGroup-', variables('locationCode'))]",
"dcrName": "[if(empty(parameters('userWorkspaceId')), concat('MicrosoftDefenderForSQL-', parameters('workspaceRegion'), '-dcr'), concat('D4SQL-', replace(parameters('userWorkspaceId'), '-', ''), '-dcr'))]",
"dcrId": "[if(parameters('bringYourOwnDcr'), parameters('dcrResourceId'), concat('/subscriptions/', variables('subscriptionId'), '/resourceGroups/', variables('defaultRGName'), '/providers/Microsoft.Insights/dataCollectionRules/', variables('dcrName')))]",
"dcraName": "[concat(parameters('vmName'),'/Microsoft.Insights/MicrosoftDefenderForSQL-RulesAssociation')]"
},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/providers/dataCollectionRuleAssociations",
"name": "[variables('dcraName')]",
"apiVersion": "2021-04-01",
"properties": {
"description": "Configure association between Arc-enabled SQL Server and the Microsoft Defender for SQL user-defined DCR. Deleting this association will break the detection of security vulnerabilities for this Arc-enabled SQL Server.",
"dataCollectionRuleId": "[variables('dcrId')]"
}
}
]
}
}
}
}
}
},
"versions": [
"1.3.0",
"1.2.0",
"1.1.1",
"1.1.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/2227e1f1-23dd-4c3a-85a9-7024a401d8b2",
"name": "2227e1f1-23dd-4c3a-85a9-7024a401d8b2"
}Bylaw2227e1f1-23dd-4c3a-85a9-7024a401d8b2.bylaw.ps1 · 64 lines
# Converted from MDC_DfSQL_AMA_UserWorkspacePipeline_DCRA_Arc.json by ConvertTo-Bylaw.
Policy '2227e1f1-23dd-4c3a-85a9-7024a401d8b2' {
Properties @{
DisplayName = 'Configure Arc-enabled SQL Servers with Data Collection Rule Association to Microsoft Defender for SQL user-defined DCR'
Description = 'Configure association between Arc-enabled SQL Servers and the Microsoft Defender for SQL user-defined DCR. Deleting this association will break the detection of security vulnerabilities for this Arc-enabled SQL Servers.'
Category = 'Security Center'
Version = '1.3.0'
PolicyVersion = '1.3.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter WorkspaceRegion @{
Type = 'String'
DisplayName = 'Workspace region'
Description = 'Region of the Log Analytics workspace destination for the Data Collection Rule.'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter UserWorkspaceId @{
Default = ''
DisplayName = 'Workspace Id'
Description = 'Workspace Id of the Log Analytics workspace destination for the Data Collection Rule.'
}
Parameter BringYourOwnDcr @{
Type = 'Boolean'
AllowedValues = @($true, $false)
Default = $false
DisplayName = 'Bring your own DCR'
Description = 'Enable or disable the use of a user-defined Data Collection Rule.'
}
Parameter DcrResourceId @{
Default = ''
DisplayName = 'DCR Resource Id'
Description = 'Resource Id of the user-defined Data Collection Rule.'
}
Resource 'Microsoft.HybridCompute/machines' {
When {
Field osName | Must -Be 'Windows'
}
Require 'mssqlDiscovered is not true' {
Field mssqlDiscovered | Must -Not -Be 'true' -IfPresent
}
}
DeployIfNotExists 'Microsoft.Insights/dataCollectionRuleAssociations' -Role 'Monitoring Contributor', 'Log Analytics Contributor' -Name 'MicrosoftDefenderForSQL-RulesAssociation' -Effect (Param Effect) {
Deployment -TemplateFile './templates/2227e1f1-23dd-4c3a-85a9-7024a401d8b2.json' -Parameters ([ordered]@{
resourceGroup = (Arm '[resourceGroup().name]')
vmName = (Arm '[field(''name'')]')
workspaceRegion = (Param WorkspaceRegion)
userWorkspaceId = (Param UserWorkspaceId)
bringYourOwnDcr = (Param BringYourOwnDcr)
dcrResourceId = (Param DcrResourceId)
})
}
}Its deployment templates are written beside it:
templates/2227e1f1-23dd-4c3a-85a9-7024a401d8b2.json
Source: built-in-policies/policyDefinitions/Security Center/MDC_DfSQL_AMA_UserWorkspacePipeline_DCRA_Arc.json in Azure/azure-policy, under the MIT licence.
Bylaw