Gallery › Security Center › Azure built-in policies
Enable Security Center's auto provisioning of the Log Analytics agent on your subscriptions with custom workspace.
Converted Policy DeployIfNotExists Disabled Mode All Version 1.0.0
Allow Security Center to auto provision the Log Analytics agent on your subscriptions to monitor and collect security data using a custom workspace.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONASC_DINE_monitoring_agent_custom_workspace.json · 100 lines
{
"properties": {
"displayName": "Enable Security Center's auto provisioning of the Log Analytics agent on your subscriptions with custom workspace.",
"policyType": "BuiltIn",
"mode": "All",
"description": "Allow Security Center to auto provision the Log Analytics agent on your subscriptions to monitor and collect security data using a custom workspace.",
"metadata": {
"version": "1.0.0",
"category": "Security Center"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"logAnalytics": {
"type": "String",
"metadata": {
"displayName": "Log Analytics workspace",
"description": "Auto provision the Log Analytics agent on your subscriptions to monitor and collect security data using a custom workspace.",
"strongType": "omsWorkspace"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Security/autoProvisioningSettings",
"deploymentScope": "Subscription",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"existenceCondition": {
"field": "Microsoft.Security/autoProvisioningSettings/autoProvision",
"equals": "On"
},
"deployment": {
"location": "westus",
"properties": {
"mode": "incremental",
"parameters": {
"logAnalytics": {
"value": "[parameters('logAnalytics')]"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logAnalytics": {
"type": "string"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Security/autoProvisioningSettings",
"name": "default",
"apiVersion": "2017-08-01-preview",
"properties": {
"autoProvision": "On"
}
},
{
"type": "Microsoft.Security/workspaceSettings",
"apiVersion": "2017-08-01-preview",
"name": "default",
"properties": {
"workspaceId": "[parameters('logAnalytics')]",
"scope": "[subscription().id]"
}
}
]
}
}
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/8e7da0a5-0a0e-4bbc-bfc0-7773c018b616",
"name": "8e7da0a5-0a0e-4bbc-bfc0-7773c018b616"
}Bylaw8e7da0a5-0a0e-4bbc-bfc0-7773c018b616.bylaw.ps1 · 41 lines
# Converted from ASC_DINE_monitoring_agent_custom_workspace.json by ConvertTo-Bylaw.
Policy '8e7da0a5-0a0e-4bbc-bfc0-7773c018b616' {
Properties @{
DisplayName = 'Enable Security Center''s auto provisioning of the Log Analytics agent on your subscriptions with custom workspace.'
Description = 'Allow Security Center to auto provision the Log Analytics agent on your subscriptions to monitor and collect security data using a custom workspace.'
Version = '1.0.0'
Category = 'Security Center'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter LogAnalytics @{
Type = 'String'
DisplayName = 'Log Analytics workspace'
Description = 'Auto provision the Log Analytics agent on your subscriptions to monitor and collect security data using a custom workspace.'
Metadata = [ordered]@{ strongType = 'omsWorkspace' }
}
Resource 'Microsoft.Resources/subscriptions'
DeployIfNotExists 'Microsoft.Security/autoProvisioningSettings' -Role 'Contributor' -Effect (Param Effect) {
Require 'autoProvision is On' {
Field autoProvision | Must -Be 'On'
}
Deployment @{
TemplateFile = './templates/8e7da0a5-0a0e-4bbc-bfc0-7773c018b616.json'
Scope = 'Subscription'
Location = 'westus'
Parameters = [ordered]@{
logAnalytics = (Param LogAnalytics)
}
}
}
}Its deployment templates are written beside it:
templates/8e7da0a5-0a0e-4bbc-bfc0-7773c018b616.json
Source: built-in-policies/policyDefinitions/Security Center/ASC_DINE_monitoring_agent_custom_workspace.json in Azure/azure-policy, under the MIT licence.
Bylaw