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 user-defined LA workspace

Converted Initiative Version 1.2.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 in the same region as the user-defined Log Analytics workspace.

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

Azure Policy JSONMDC_DfSQL_AMA_UserWorkspace.json · 229 lines
{
  "properties": {
    "displayName": "Configure SQL VMs and Arc-enabled SQL Servers to install Microsoft Defender for SQL and AMA with a user-defined 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 in the same region as the user-defined Log Analytics workspace.",
    "version": "1.2.0",
    "metadata": {
      "category": "Security Center",
      "version": "1.2.0"
    },
    "parameters": {
      "userWorkspaceResourceId": {
        "type": "String",
        "metadata": {
          "displayName": "Workspace Resource Id",
          "description": "Workspace resource Id of the Log Analytics workspace destination for the Data Collection Rule.",
          "strongType": "omsWorkspace"
        }
      },
      "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": ""
      },
      "bringYourOwnDcr": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Bring your own DCR",
          "description": "Enable this to use your own Data Collection Rule. The pre-created Data Collection Rule MUST exist otherwise the policy deployment will fail. If enabled, ensure that the Data Collection Rule Resource ID parameter matches the pre-created Data Collection Rule Resource ID. If not enabled, the policy will create a new Data Collection Rule per subscription."
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": false
      },
      "dcrResourceId": {
        "type": "String",
        "metadata": {
          "displayName": "Data Collection Rule Resource ID",
          "description": "The resource ID of the user-defined Data Collection Rule. This parameter is only used when bringYourOwnDcr 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')]"
          },
          "bringYourOwnDcr": {
            "value": "[parameters('bringYourOwnDcr')]"
          },
          "dcrResourceId": {
            "value": "[parameters('dcrResourceId')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/04754ef9-9ae3-4477-bf17-86ef50026304",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_UserWorkspacePipeline_VM",
        "definitionVersion": "1.*.*",
        "parameters": {
          "userWorkspaceResourceId": {
            "value": "[parameters('userWorkspaceResourceId')]"
          },
          "workspaceRegion": {
            "value": "[parameters('workspaceRegion')]"
          },
          "userWorkspaceId": {
            "value": "[parameters('userWorkspaceId')]"
          },
          "enableCollectionOfSqlQueriesForSecurityResearch": {
            "value": "[parameters('enableCollectionOfSqlQueriesForSecurityResearch')]"
          },
          "bringYourOwnDcr": {
            "value": "[parameters('bringYourOwnDcr')]"
          }
        }
      },
      {
        "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/63d03cbd-47fd-4ee1-8a1c-9ddf07303de0",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_UserWorkspacePipeline_Arc",
        "definitionVersion": "1.*.*",
        "parameters": {
          "userWorkspaceResourceId": {
            "value": "[parameters('userWorkspaceResourceId')]"
          },
          "workspaceRegion": {
            "value": "[parameters('workspaceRegion')]"
          },
          "userWorkspaceId": {
            "value": "[parameters('userWorkspaceId')]"
          },
          "enableCollectionOfSqlQueriesForSecurityResearch": {
            "value": "[parameters('enableCollectionOfSqlQueriesForSecurityResearch')]"
          },
          "bringYourOwnDcr": {
            "value": "[parameters('bringYourOwnDcr')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/2227e1f1-23dd-4c3a-85a9-7024a401d8b2",
        "policyDefinitionReferenceId": "MDC_DfSQL_AMA_UserWorkspacePipeline_DCRA_Arc",
        "definitionVersion": "1.*.*",
        "parameters": {
          "workspaceRegion": {
            "value": "[parameters('workspaceRegion')]"
          },
          "userWorkspaceId": {
            "value": "[parameters('userWorkspaceId')]"
          },
          "bringYourOwnDcr": {
            "value": "[parameters('bringYourOwnDcr')]"
          },
          "dcrResourceId": {
            "value": "[parameters('dcrResourceId')]"
          }
        }
      }
    ],
    "versions": [
      "1.2.0",
      "1.1.1",
      "1.1.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/de01d381-bae9-4670-8870-786f89f49e26",
  "name": "de01d381-bae9-4670-8870-786f89f49e26"
}
Bylawde01d381-bae9-4670-8870-786f89f49e26.bylaw.ps1 · 148 lines
# Converted from MDC_DfSQL_AMA_UserWorkspace.json by ConvertTo-Bylaw.
Initiative 'de01d381-bae9-4670-8870-786f89f49e26' {

    Properties @{
        DisplayName   = 'Configure SQL VMs and Arc-enabled SQL Servers to install Microsoft Defender for SQL and AMA with a user-defined 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 in the same region as the user-defined Log Analytics workspace.'
        Category      = 'Security Center'
        Version       = '1.2.0'
        PolicyVersion = '1.2.0'
    }

    Parameter UserWorkspaceResourceId @{
        Type        = 'String'
        DisplayName = 'Workspace Resource Id'
        Description = 'Workspace resource Id of the Log Analytics workspace destination for the Data Collection Rule.'
        Metadata    = [ordered]@{ strongType = 'omsWorkspace' }
    }
    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.'
    }
    Parameter BringYourOwnDcr @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $false
        DisplayName   = 'Bring your own DCR'
        Description   = 'Enable this to use your own Data Collection Rule. The pre-created Data Collection Rule MUST exist otherwise the policy deployment will fail. If enabled, ensure that the Data Collection Rule Resource ID parameter matches the pre-created Data Collection Rule Resource ID. If not enabled, the policy will create a new Data Collection Rule per subscription.'
    }
    Parameter DcrResourceId @{
        Default     = ''
        DisplayName = 'Data Collection Rule Resource ID'
        Description = 'The resource ID of the user-defined Data Collection Rule. This parameter is only used when bringYourOwnDcr 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)
            bringYourOwnDcr = (Param BringYourOwnDcr)
            dcrResourceId   = (Param DcrResourceId)
        }
    }

    PolicyDefinition @{
        Id          = '04754ef9-9ae3-4477-bf17-86ef50026304'
        ReferenceId = 'MDC_DfSQL_AMA_UserWorkspacePipeline_VM'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            userWorkspaceResourceId                         = (Param UserWorkspaceResourceId)
            workspaceRegion                                 = (Param WorkspaceRegion)
            userWorkspaceId                                 = (Param UserWorkspaceId)
            enableCollectionOfSqlQueriesForSecurityResearch = (Param EnableCollectionOfSqlQueriesForSecurityResearch)
            bringYourOwnDcr                                 = (Param BringYourOwnDcr)
        }
    }

    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          = '63d03cbd-47fd-4ee1-8a1c-9ddf07303de0'
        ReferenceId = 'MDC_DfSQL_AMA_UserWorkspacePipeline_Arc'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            userWorkspaceResourceId                         = (Param UserWorkspaceResourceId)
            workspaceRegion                                 = (Param WorkspaceRegion)
            userWorkspaceId                                 = (Param UserWorkspaceId)
            enableCollectionOfSqlQueriesForSecurityResearch = (Param EnableCollectionOfSqlQueriesForSecurityResearch)
            bringYourOwnDcr                                 = (Param BringYourOwnDcr)
        }
    }

    PolicyDefinition @{
        Id          = '2227e1f1-23dd-4c3a-85a9-7024a401d8b2'
        ReferenceId = 'MDC_DfSQL_AMA_UserWorkspacePipeline_DCRA_Arc'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            workspaceRegion = (Param WorkspaceRegion)
            userWorkspaceId = (Param UserWorkspaceId)
            bringYourOwnDcr = (Param BringYourOwnDcr)
            dcrResourceId   = (Param DcrResourceId)
        }
    }
}

Members (8)

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