Gallery › Security Center › Azure built-in policies
Configure Arc-enabled SQL Servers to automatically install Azure Monitor Agent
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.3.0
Automate the deployment of Azure Monitor Agent extension on your Windows Arc-enabled SQL Servers. Learn more: https://aka.ms/AMAOverview.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONMDC_DfSQL_DeployWindowsAMA_Arc.json · 126 lines
{
"properties": {
"displayName": "Configure Arc-enabled SQL Servers to automatically install Azure Monitor Agent",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Automate the deployment of Azure Monitor Agent extension on your Windows Arc-enabled SQL Servers. Learn more: https://aka.ms/AMAOverview.",
"version": "1.3.0",
"metadata": {
"version": "1.3.0",
"category": "Security Center"
},
"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'), '/AzureMonitorWindowsAgent') ]",
"evaluationDelay": "AfterProvisioning",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/cd570a14-e51a-42ad-bac8-bafd67325302"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.HybridCompute/machines/extensions/type",
"equals": "AzureMonitorWindowsAgent"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/publisher",
"equals": "Microsoft.Azure.Monitor"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
"equals": "Succeeded"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"vmName": {
"value": "[field('Name')]"
},
"location": {
"value": "[field('location')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"variables": {
"extensionName": "AzureMonitorWindowsAgent",
"extensionPublisher": "Microsoft.Azure.Monitor",
"extensionType": "AzureMonitorWindowsAgent"
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/', variables('extensionName'))]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"tags": {
"createdBy": "MicrosoftDefenderForSQL"
},
"apiVersion": "2022-11-10",
"properties": {
"publisher": "[variables('extensionPublisher')]",
"type": "[variables('extensionType')]",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true
}
}
]
}
}
}
}
}
},
"versions": [
"1.3.0",
"1.2.2",
"1.2.1-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/3592ff98-9787-443a-af59-4505d0fe0786",
"name": "3592ff98-9787-443a-af59-4505d0fe0786"
}Bylaw3592ff98-9787-443a-af59-4505d0fe0786.bylaw.ps1 · 42 lines
# Converted from MDC_DfSQL_DeployWindowsAMA_Arc.json by ConvertTo-Bylaw.
Policy '3592ff98-9787-443a-af59-4505d0fe0786' {
Properties @{
DisplayName = 'Configure Arc-enabled SQL Servers to automatically install Azure Monitor Agent'
Description = 'Automate the deployment of Azure Monitor Agent extension on your Windows Arc-enabled SQL Servers. Learn more: https://aka.ms/AMAOverview.'
Version = '1.3.0'
Category = 'Security Center'
PolicyVersion = '1.3.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 'Azure Connected Machine Resource Administrator' -Name (Arm '[concat(field(''Name''), ''/AzureMonitorWindowsAgent'') ]') -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
Require 'type, publisher and provisioningState are as required' {
Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'AzureMonitorWindowsAgent'
Field publisher | Must -Be 'Microsoft.Azure.Monitor'
Field provisioningState | Must -Be 'Succeeded'
}
Deployment -TemplateFile './templates/3592ff98-9787-443a-af59-4505d0fe0786.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''Name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/3592ff98-9787-443a-af59-4505d0fe0786.json
Source: built-in-policies/policyDefinitions/Security Center/MDC_DfSQL_DeployWindowsAMA_Arc.json in Azure/azure-policy, under the MIT licence.
Bylaw