Gallery › SQL › Azure Landing Zones Library
[Deprecated]: Deploy SQL Database vulnerability Assessments
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.1-deprecated Deprecated
Deploy SQL Database vulnerability Assessments when it not exist in the deployment. Superseded by https://www.azadvertizer.net/azpolicyadvertizer/Deploy-Sql-vulnerabilityAssessments_20230706.html
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONDeploy-Sql-vulnerabilityAssessments.alz_policy_definition.json · 143 lines
{
"name": "Deploy-Sql-vulnerabilityAssessments",
"properties": {
"description": "Deploy SQL Database vulnerability Assessments when it not exist in the deployment. Superseded by https://www.azadvertizer.net/azpolicyadvertizer/Deploy-Sql-vulnerabilityAssessments_20230706.html",
"displayName": "[Deprecated]: Deploy SQL Database vulnerability Assessments",
"metadata": {
"alzCloudEnvironments": [
"AzureCloud",
"AzureChinaCloud",
"AzureUSGovernment"
],
"category": "SQL",
"deprecated": true,
"source": "https://github.com/Azure/Enterprise-Scale/",
"supersededBy": "Deploy-Sql-vulnerabilityAssessments_20230706",
"version": "1.0.1-deprecated"
},
"mode": "Indexed",
"parameters": {
"effect": {
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists",
"metadata": {
"description": "Enable or disable the execution of the policy",
"displayName": "Effect"
},
"type": "String"
},
"vulnerabilityAssessmentsEmail": {
"metadata": {
"description": "The email address to send alerts. For multiple emails, format in the following 'email1@contoso.com;email2@contoso.com'",
"displayName": "The email address to send alerts. For multiple emails, format in the following 'email1@contoso.com;email2@contoso.com'"
},
"type": "String"
},
"vulnerabilityAssessmentsStorageID": {
"metadata": {
"assignPermissions": true,
"description": "The storage account ID to store assessments",
"displayName": "The storage account ID to store assessments"
},
"type": "String"
}
},
"policyRule": {
"if": {
"equals": "Microsoft.Sql/servers/databases",
"field": "type"
},
"then": {
"details": {
"deployment": {
"properties": {
"mode": "Incremental",
"parameters": {
"location": {
"value": "[field('location')]"
},
"sqlServerDataBaseName": {
"value": "[field('name')]"
},
"sqlServerName": {
"value": "[first(split(field('fullname'),'/'))]"
},
"vulnerabilityAssessmentsEmail": {
"value": "[parameters('vulnerabilityAssessmentsEmail')]"
},
"vulnerabilityAssessmentsStorageID": {
"value": "[parameters('vulnerabilityAssessmentsStorageID')]"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"location": {
"type": "String"
},
"sqlServerDataBaseName": {
"type": "String"
},
"sqlServerName": {
"type": "String"
},
"vulnerabilityAssessmentsEmail": {
"type": "String"
},
"vulnerabilityAssessmentsStorageID": {
"type": "String"
}
},
"resources": [
{
"apiVersion": "2017-03-01-preview",
"name": "[concat(parameters('sqlServerName'),'/',parameters('sqlServerDataBaseName'),'/default')]",
"properties": {
"recurringScans": {
"emailSubscriptionAdmins": false,
"emails": [
"[parameters('vulnerabilityAssessmentsEmail')]"
],
"isEnabled": true
},
"storageAccountAccessKey": "[listkeys(parameters('vulnerabilityAssessmentsStorageID'), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]",
"storageContainerPath": "[concat('https://', last( split(parameters('vulnerabilityAssessmentsStorageID') , '/') ) , '.blob.core.windows.net/vulneraabilitylogs')]"
},
"type": "Microsoft.Sql/servers/databases/vulnerabilityAssessments"
}
],
"variables": {}
}
}
},
"existenceCondition": {
"allOf": [
{
"equals": "[parameters('vulnerabilityAssessmentsEmail')]",
"field": "Microsoft.Sql/servers/databases/vulnerabilityAssessments/recurringScans.emails"
},
{
"equals": true,
"field": "Microsoft.Sql/servers/databases/vulnerabilityAssessments/recurringScans.isEnabled"
}
]
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/056cd41c-7e88-42e1-933e-88ba6a50c9c3",
"/providers/Microsoft.Authorization/roleDefinitions/749f88d5-cbae-40b8-bcfc-e573ddc772fa",
"/providers/Microsoft.Authorization/roleDefinitions/17d1049b-9a84-46fb-8f53-869881c3d3ab"
],
"type": "Microsoft.Sql/servers/databases/vulnerabilityAssessments"
},
"effect": "[parameters('effect')]"
}
},
"policyType": "Custom"
},
"type": "Microsoft.Authorization/policyDefinitions"
}BylawDeploy-Sql-vulnerabilityAssessments.bylaw.ps1 · 47 lines
# Converted from Deploy-Sql-vulnerabilityAssessments.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deploy-Sql-vulnerabilityAssessments' {
Properties @{
DisplayName = '[Deprecated]: Deploy SQL Database vulnerability Assessments'
Description = 'Deploy SQL Database vulnerability Assessments when it not exist in the deployment. Superseded by https://www.azadvertizer.net/azpolicyadvertizer/Deploy-Sql-vulnerabilityAssessments_20230706.html'
Category = 'SQL'
Deprecated = $true
Version = '1.0.1-deprecated'
Mode = 'Indexed'
Metadata = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/'; supersededBy = 'Deploy-Sql-vulnerabilityAssessments_20230706' }
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter VulnerabilityAssessmentsEmail @{
Type = 'String'
DisplayName = 'The email address to send alerts. For multiple emails, format in the following ''email1@contoso.com;email2@contoso.com'''
Description = 'The email address to send alerts. For multiple emails, format in the following ''email1@contoso.com;email2@contoso.com'''
}
Parameter VulnerabilityAssessmentsStorageID @{
Type = 'String'
DisplayName = 'The storage account ID to store assessments'
Description = 'The storage account ID to store assessments'
Metadata = [ordered]@{ assignPermissions = $true }
}
Resource 'Microsoft.Sql/servers/databases'
DeployIfNotExists 'Microsoft.Sql/servers/databases/vulnerabilityAssessments' -Role 'SQL Security Manager', 'Monitoring Contributor', 'Storage Account Contributor' -Effect (Param Effect) {
Require 'recurringScans.emails and recurringScans.isEnabled are as required' {
Field recurringScans.emails | Must -Be (Param VulnerabilityAssessmentsEmail)
Field recurringScans.isEnabled | Must -Be $true
}
Deployment -TemplateFile './templates/Deploy-Sql-vulnerabilityAssessments.json' -Parameters ([ordered]@{
location = (Arm '[field(''location'')]')
sqlServerDataBaseName = (Arm '[field(''name'')]')
sqlServerName = (Arm '[first(split(field(''fullname''),''/''))]')
vulnerabilityAssessmentsEmail = (Param VulnerabilityAssessmentsEmail)
vulnerabilityAssessmentsStorageID = (Param VulnerabilityAssessmentsStorageID)
})
}
}Its deployment templates are written beside it:
templates/Deploy-Sql-vulnerabilityAssessments.json
Source: policy_definitions/Deploy-Sql-vulnerabilityAssessments.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.
Bylaw