Project: KICS (Provisioning / Security & Compliance)
File: c09cdac2-7670-458a-bf6c-efad6880973a.md

title: SQL Server Database With Unrecommended Retention Days hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: c09cdac2-7670-458a-bf6c-efad6880973a Query name: SQL Server Database With Unrecommended Retention Days Platform: AzureResourceManager Severity: <span style="color:#edd57e">Low</span> Category: Observability URL: SQL Server Database Auditing Settings should keep the audit logs in the storage account for at least 90 days<br> ```json title="Positive test num. 1 - json file" hl_lines="48" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 50, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} } ``` ```json title="Positive test num. 2 - json file" hl_lines="43" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} } ``` ```json title="Positive test num. 3 - json file" hl_lines="50" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type":

"apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 50, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ``` <details><summary>Positive test num. 4 - json file</summary> ```json hl_lines="45" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ``` </details> ```json title="Negative test num. 1 - json file" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} } ``` ```json title="Negative test num. 2 - json file" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled", "dependsOn": [ "[resourceId('Microsoft.Sql/servers/databases', 'sqlServer1/sqlDatabase1')]" ] } } ] } ] } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ```