我正在使用 ARMTemplate 部署 AzureSqlServer。我想使用 ARMTemplate 启用审计和威胁检测。下面是将 auditingtype 设置为“Table”的代码:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The name of the SQL Server."
}
},
"location": {
"type": "string",
"defaultValue": "South Central US",
"allowedValues": [
"Central US",
"East Asia",
"East US",
"Japan East",
"Japan West",
"North Europe",
"South Central US",
"Southeast Asia",
"West Europe",
"West US",
"East US 2"
],
"metadata": {
"description": "The location where SQL server will be deployed."
}
},
"administratorLogin": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The account name to use for the database server administrator."
}
},
"administratorLoginPassword": {
"type": "securestring",
"minLength": 1,
"metadata": {
"description": "The password to use for the database server administrator."
}
},
"serverVersion": {
"type": "string",
"defaultValue": "12.0",
"allowedValues": [
"12.0"
],
"metadata": {
"description": "The server version."
}
},
"deploymentVersion": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The deployment version tag."
}
},
"deploymentType": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The deployment type tag."
}
},
"auditStorageAccountName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the storage account where diagnostics logs will be written"
}
},
"auditAlertEmailaddress": {
"type": "string",
"metadata": {
"description": "Specifies the email address for alerts"
}
},
"logsRetentionInDays": {
"type": "string",
"metadata": {
"description": "Specifies the number of days that logs are gonna be kept. If you do not want to apply any retention policy and retain data forever, set value to 0."
}
},
"threatDetection": {
"type": "string",
"defaultValue": "Disabled",
"allowedValues": [
"Enabled",
"Disabled"
],
"metadata": {
"description": "Azure SQL Server Threat Detection."
}
},
"auditing": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
],
"metadata": {
"description": "Azure SQL Server auditing."
}
}
},
"variables": { },
"resources": [
{
"name": "[parameters('serverName')]",
"type": "Microsoft.Sql/servers",
"location": "[parameters('location')]",
"apiVersion": "2014-04-01-preview",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"version": "[parameters('serverVersion')]"
},
"tags": {
"deploymentVersion": "[parameters('deploymentVersion')]",
"deploymentType": "[parameters('deploymentType')]"
},
"resources": [
{
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
],
"location": "[parameters('location')]",
"name": "AllowAllWindowsAzureIps",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
},
"type": "firewallrules"
},
{
"apiVersion": "2014-04-01-preview",
"type": "auditingPolicies",
"name": "DefaultAuditPolicy",
"dependsOn": [
"[parameters('serverName')]"
],
"properties": {
"State": "[parameters('auditing')]",
"storageAccountName": "[parameters('auditStorageAccountName')]",
"storageEndpoint": "[concat('https://', parameters('auditStorageAccountName'), '.blob.core.windows.net/')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('auditStorageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]",
"storageAccountResourceGroupName": "[resourceGroup().name]",
"storageAccountSubscriptionId": "[subscription().subscriptionId]",
"eventTypesToAudit": "All"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "securityAlertPolicies",
"name": "DefaultSecurityAlert",
"dependsOn": [
"[parameters('serverName')]",
"[concat('Microsoft.Sql/servers/', parameters('serverName'), '/auditingPolicies/DefaultAuditPolicy')]"
],
"properties": {
"state": "[parameters('threatDetection')]",
"disabledAlerts": "",
"emailAddresses": "[parameters('auditAlertEmailaddress')]",
"emailAccountAdmins": "Enabled",
"retentionDays": "[parameters('logsRetentionInDays')]",
"storageEndpoint": "[concat('https://', parameters('auditStorageAccountName'), '.blob.core.windows.net/')]",
"storageAccountAccessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('auditStorageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]"
}
}
]
}
]
}
这段代码给出的错误如下:
部署模板验证失败:'资源'Microsoft.Sql/servers/test2aa/auditingPolicies/DefaultAuditPolicy'未在模板中定义
如果我更改“类型”:“auditingPolicies”,那么我还需要更改 api 版本。当我修改 apiversion 并重新部署模板时,我得到“处理请求时发生错误”并且模板失败
如何使用 ARMTemplate 将 AuditingType 设置为“Blob”?