Bylaw

Gallery › Security Center › Azure built-in policies

Configure SQL VMs and Arc-enabled SQL Servers to install Microsoft Defender for SQL and AMA with a LA workspace

Converted Initiative Version 1.3.0

Microsoft Defender for SQL collects events from the agents and uses them to provide security alerts and tailored hardening tasks (recommendations). Creates a resource group and a Data Collection Rule and Log Analytics workspace in the same region as the machine.

ConvertTo-Bylaw converted this initiative, and proved that the file compiles back to the same definition.

Azure Policy JSONMDC_DfSQL_AMA_DefaultWorkspace.json · 162 lines
{
  "properties": {
    "displayName": "Configure SQL VMs and Arc-enabled SQL Servers to install Microsoft Defender for SQL and AMA with a LA workspace",
    "policyType": "BuiltIn",
    "description": "Microsoft Defender for SQL collects events from the agents and uses them to provide security alerts and tailored hardening tasks (recommendations). Creates a resource group and a Data Collection Rule and Log Analytics workspace in the same region as the machine.",
    "version": "1.3.0",
    "metadata": {
      "category": "Security Center",
      "version": "1.3.0"
    },
    "parameters": {
      "workspaceRegion": {
        "type": "String",
        "metadata": {
          "displayName": "Workspace region",
          "description": "Region of the Log Analytics workspace destination for the Data Collection Rule.",
          "strongType": "location"
        },
        "defaultValue": ""
      },
      "userWorkspaceId": {
        "type": "String",
        "metadata": {
          "displayName": "Workspace Id",
          "description": "Workspace Id of the Log Analytics workspace destination for the Data Collection Rule."
        },
        "defaultValue": ""
      },
      "enableCollectionOfSqlQueriesForSecurityResearch": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Enable collection of SQL queries for security research",
          "description": "Enable or disable the collection of SQL queries for security research."
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": false
      },
      "builtInIdentityResourceGroupLocation": {
        "type": "String",
        "metadata": {
          "displayName": "User-Assigned Managed Identity Resource Group Location",
          "description": "The location of the resource group 'Built-In-Identity-RG' created by the policy."
        },
        "defaultValue": "eastus"
      },
      "bringYourOwnUserAssignedManagedIdentity": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Bring your own User-Assigned Managed Identity",
          "description": "Enable this to use your own user-assigned managed identity. The pre-created identity MUST exist otherwise the policy deployment will fail. If enabled, ensure that the user-assigned managed identity resource ID parameter matches the pre-created user-assigned managed identity resource ID. If not enabled, the policy will create a new user-assigned managed identitiy per subscription, in a new resource group named 'Built-In-Identity-RG'."
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": false
      },
      "userAssignedIdentityResourceId": {
        "type": "String",
        "metadata": {
          "displayName": "User-Assigned Managed Identity Resource ID",
          "description": "The resource ID of the pre-created user-assigned managed identity. This parameter is only used when bringYourOwnUserAssignedManagedIdentity is set to true"
        },
        "defaultValue": ""
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/09963c90-6ee7-4215-8d26-1cc660a1682f",
        "policyDefinitionReferenceId": "MDC_DfSQL_AddUserAssignedIdentity_VM",
        "definitionVersion": "1.*.*",
        "parameters": {
          "builtInIdentityResourceGroupLocation": {
            "value": "[parameters('builtInIdentityResourceGroupLocation')]"
          },
          "bringYourOwnUserAssignedManagedIdentity": {
            "value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
          },
          "userAssignedIdentityResourceId": {
            "value": "[parameters('userAssignedIdentityResourceId')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/f91991d1-5383-4c95-8ee5-5ac423dd8bb1",
        "policyDefinitionReferenceId": "MDC_DfSQL_DeployWindowsAMA_VM",
        "definitionVersion": "1.*.*",
        "parameters": {
          "bringYourOwnUserAssignedManagedIdentity": {
            "value": "[parameters('bringYourOwnUserAssignedManagedIdentity')]"
          },
          "userAssignedIdentityResourceId": {
            "value": "[parameters('userAssignedIdentityResourceId')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/ddca0ddc-4e9d-4bbb-92a1-f7c4dd7ef7ce",
        "policyDefinitionReferenceId": "MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_VM",
        "definitionVersion": "1.*.*",
        "parameters": {
          "workspaceRegion": {
            "value": "[parameters('workspaceRegion')]"
          },
          "userWorkspaceId": {
            "value": "[parameters('userWorkspaceId')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/242300d6-1bfc-4d64-8d01-cee583709ebd",
        "policyDefinitionReferenceId": "MDC_DfSQL_DeployDefaultWorkspace",
        "definitionVersion": "1.*.*"
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/c859b78a-a128-4376-a838-e97ce6625d16",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_DefaultPipeline_VM",
        "definitionVersion": "1.*.*",
        "parameters": {
          "enableCollectionOfSqlQueriesForSecurityResearch": {
            "value": "[parameters('enableCollectionOfSqlQueriesForSecurityResearch')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/3592ff98-9787-443a-af59-4505d0fe0786",
        "policyDefinitionReferenceId": "MDC_DfSQL_DeployWindowsAMA_Arc",
        "definitionVersion": "1.*.*"
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/65503269-6a54-4553-8a28-0065a8e6d929",
        "policyDefinitionReferenceId": "MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_Arc",
        "definitionVersion": "1.*.*"
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/da0fd392-9669-4ad4-b32c-ca46aaa6c21f",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_DefaultPipeline_Arc",
        "definitionVersion": "1.*.*",
        "parameters": {
          "enableCollectionOfSqlQueriesForSecurityResearch": {
            "value": "[parameters('enableCollectionOfSqlQueriesForSecurityResearch')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/cbdd12e1-193a-445c-9926-560118c6daaa",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_DefaultPipeline_DCRA_Arc",
        "definitionVersion": "1.*.*"
      }
    ],
    "versions": [
      "1.3.0",
      "1.2.1",
      "1.2.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/d7c3ea3a-edf3-4bd5-bd64-d5b635b05393",
  "name": "d7c3ea3a-edf3-4bd5-bd64-d5b635b05393"
}
Bylawd7c3ea3a-edf3-4bd5-bd64-d5b635b05393.bylaw.ps1 · 120 lines
# Converted from MDC_DfSQL_AMA_DefaultWorkspace.json by ConvertTo-Bylaw.
Initiative 'd7c3ea3a-edf3-4bd5-bd64-d5b635b05393' {

    Properties @{
        DisplayName   = 'Configure SQL VMs and Arc-enabled SQL Servers to install Microsoft Defender for SQL and AMA with a LA workspace'
        Description   = 'Microsoft Defender for SQL collects events from the agents and uses them to provide security alerts and tailored hardening tasks (recommendations). Creates a resource group and a Data Collection Rule and Log Analytics workspace in the same region as the machine.'
        Category      = 'Security Center'
        Version       = '1.3.0'
        PolicyVersion = '1.3.0'
    }

    Parameter WorkspaceRegion @{
        Default     = ''
        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 EnableCollectionOfSqlQueriesForSecurityResearch @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $false
        DisplayName   = 'Enable collection of SQL queries for security research'
        Description   = 'Enable or disable the collection of SQL queries for security research.'
    }
    Parameter BuiltInIdentityResourceGroupLocation @{
        Default     = 'eastus'
        DisplayName = 'User-Assigned Managed Identity Resource Group Location'
        Description = 'The location of the resource group ''Built-In-Identity-RG'' created by the policy.'
    }
    Parameter BringYourOwnUserAssignedManagedIdentity @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $false
        DisplayName   = 'Bring your own User-Assigned Managed Identity'
        Description   = 'Enable this to use your own user-assigned managed identity. The pre-created identity MUST exist otherwise the policy deployment will fail. If enabled, ensure that the user-assigned managed identity resource ID parameter matches the pre-created user-assigned managed identity resource ID. If not enabled, the policy will create a new user-assigned managed identitiy per subscription, in a new resource group named ''Built-In-Identity-RG''.'
    }
    Parameter UserAssignedIdentityResourceId @{
        Default     = ''
        DisplayName = 'User-Assigned Managed Identity Resource ID'
        Description = 'The resource ID of the pre-created user-assigned managed identity. This parameter is only used when bringYourOwnUserAssignedManagedIdentity is set to true'
    }

    PolicyDefinition @{
        Id          = '09963c90-6ee7-4215-8d26-1cc660a1682f'
        ReferenceId = 'MDC_DfSQL_AddUserAssignedIdentity_VM'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            builtInIdentityResourceGroupLocation    = (Param BuiltInIdentityResourceGroupLocation)
            bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
            userAssignedIdentityResourceId          = (Param UserAssignedIdentityResourceId)
        }
    }

    PolicyDefinition @{
        Id          = 'f91991d1-5383-4c95-8ee5-5ac423dd8bb1'
        ReferenceId = 'MDC_DfSQL_DeployWindowsAMA_VM'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            bringYourOwnUserAssignedManagedIdentity = (Param BringYourOwnUserAssignedManagedIdentity)
            userAssignedIdentityResourceId          = (Param UserAssignedIdentityResourceId)
        }
    }

    PolicyDefinition @{
        Id          = 'ddca0ddc-4e9d-4bbb-92a1-f7c4dd7ef7ce'
        ReferenceId = 'MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_VM'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            workspaceRegion = (Param WorkspaceRegion)
            userWorkspaceId = (Param UserWorkspaceId)
        }
    }

    PolicyDefinition @{
        Id          = '242300d6-1bfc-4d64-8d01-cee583709ebd'
        ReferenceId = 'MDC_DfSQL_DeployDefaultWorkspace'
        Version     = '1.*.*'
    }

    PolicyDefinition @{
        Id          = 'c859b78a-a128-4376-a838-e97ce6625d16'
        ReferenceId = 'MDC_DfSQL_AMA_DefaultPipeline_VM'
        Version     = '1.*.*'
        Parameters  = @{
            enableCollectionOfSqlQueriesForSecurityResearch = (Param EnableCollectionOfSqlQueriesForSecurityResearch)
        }
    }

    PolicyDefinition @{
        Id          = '3592ff98-9787-443a-af59-4505d0fe0786'
        ReferenceId = 'MDC_DfSQL_DeployWindowsAMA_Arc'
        Version     = '1.*.*'
    }

    PolicyDefinition @{
        Id          = '65503269-6a54-4553-8a28-0065a8e6d929'
        ReferenceId = 'MDC_DfSQL_DeployMicrosoftDefenderForSQLWindowsAgent_Arc'
        Version     = '1.*.*'
    }

    PolicyDefinition @{
        Id          = 'da0fd392-9669-4ad4-b32c-ca46aaa6c21f'
        ReferenceId = 'MDC_DfSQL_AMA_DefaultPipeline_Arc'
        Version     = '1.*.*'
        Parameters  = @{
            enableCollectionOfSqlQueriesForSecurityResearch = (Param EnableCollectionOfSqlQueriesForSecurityResearch)
        }
    }

    PolicyDefinition @{
        Id          = 'cbdd12e1-193a-445c-9926-560118c6daaa'
        ReferenceId = 'MDC_DfSQL_AMA_DefaultPipeline_DCRA_Arc'
        Version     = '1.*.*'
    }
}

Members (9)

Source: built-in-policies/policySetDefinitions/Security Center/MDC_DfSQL_AMA_DefaultWorkspace.json in Azure/azure-policy, under the MIT licence.