我无法找到任何有关在发布管道中启用自动调整的文档,即通过ARM模板或powershell,也无法在github arm快速入门中找到。
我可以在资源浏览器中看到自动调整,但我不知道这在ARM模板中是如何反映的。
{
"name": "Microsoft.Sql/servers/automaticTuning/read",
"display": {
"provider": "Microsoft SQL Database",
"resource": "Server Automatic Tuning",
"operation": "Get automatic tuning settings for the server",
"description": "Returns automatic tuning settings for the server"
}
},
{
"name": "Microsoft.Sql/servers/automaticTuning/write",
"display": {
"provider": "Microsoft SQL Database",
"resource": "Server Automatic Tuning",
"operation": "Update automatic tuning settings for the server",
"description": "Updates automatic tuning settings for the server and returns updated settings"
}
},
答案 0 :(得分:7)
现在可以在逻辑服务器或数据库级别通过ARM模板设置自动调整选项。我已经使用Azure门户上的Automation Script
刀片来获取这些信息:
SQL服务器级别:
{
"type": "Microsoft.Sql/servers/advisors",
"name": "[concat(parameters('sqlserverName'), '/', 'ForceLastGoodPlan')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]"
]
},
{
"type": "Microsoft.Sql/servers/advisors",
"name": "[concat(parameters('sqlserverName'), '/', 'CreateIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]"
]
},
{
"type": "Microsoft.Sql/servers/advisors",
"name": "[concat(parameters('sqlserverName'), '/', 'DropIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]"
]
},
{
"type": "Microsoft.Sql/servers/advisors",
"name": "[concat(parameters('sqlserverName'), '/', 'DbParameterization')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]"
]
},
{
"type": "Microsoft.Sql/servers/advisors",
"name": "[concat(parameters('sqlserverName'), '/', 'DefragmentIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]"
]
}
数据库级别:
{
"type": "Microsoft.Sql/servers/databases/advisors",
"name": "[concat(parameters('sqlserverName'), '/', parameters('databaseName'), '/', 'ForceLastGoodPlan')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlserverName'), parameters('databaseName'))]"
]
},
{
"type": "Microsoft.Sql/servers/databases/advisors",
"name": "[concat(parameters('sqlserverName'), '/', parameters('databaseName'), '/', 'CreateIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlserverName'), parameters('databaseName'))]"
]
},
{
"type": "Microsoft.Sql/servers/databases/advisors",
"name": "[concat(parameters('sqlserverName'), '/', parameters('databaseName'), '/', 'DropIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlserverName'), parameters('databaseName'))]"
]
},
{
"type": "Microsoft.Sql/servers/databases/advisors",
"name": "[concat(parameters('sqlserverName'), '/', parameters('databaseName'), '/', 'DbParameterization')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlserverName'), parameters('databaseName'))]"
]
},
{
"type": "Microsoft.Sql/servers/databases/advisors",
"name": "[concat(parameters('sqlserverName'), '/', parameters('databaseName'), '/DefragmentIndex')]",
"apiVersion": "2014-04-01",
"scale": null,
"properties": {
"autoExecuteValue": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlserverName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlserverName'), parameters('databaseName'))]"
]
}
答案 1 :(得分:4)
Alex,正如Estienne所说,目前ARM模板不支持此功能,但还有其他方法可以做到这一点。
1)默认情况下,所有新创建的数据库都会从服务器继承自动调整设置。因此,如果在服务器级别配置自动调整,则所有新数据库将在创建时继承这些设置。
2)您可以使用T-SQL,您可以在数据库上运行以配置自动调整。以下T-SQL将在数据库级别配置自动调整:
ALTER DATABASE current SET AUTOMATIC_TUNING = AUTO | INHERIT | CUSTOM
选择AUTO,您将获得一组默认选项 - 启用CREATE_INDEX和FORCE_LAST_GOOD_PLAN。选择INHERIT,您将从服务器继承设置。选择CUSTOM,您需要明确说明所有自动调整选项。
如果您想明确启用/禁用某些选项,可以使用:
ALTER DATABASE current SET AUTOMATIC_TUNING ( FORCE_LAST_GOOD_PLAN = DEFAULT, CREATE_INDEX = ON, DROP_INDEX = OFF )
将一些选项设置为DEFAULT将获取数据库级别配置。
3)您可以使用REST API配置自动调整。像这样的东西:
PATCH /subscriptions/{SUBID}/resourceGroups/{RGNAME}/providers/Microsoft.Sql/servers/{SRVNAME}/databases/{DBNAME}/automaticTuning/current?api-version=2017-03-01-预览HTTP / 1.1
主持人:management.azure.com
授权:持票人
内容类型:application / json
缓存控制:无缓存
{"属性":{" desiredState":" Custom"," options":{" forceLastGoodPlan&#34 ;:" On"," createIndex" :" On"," dropIndex" :"关" }}}
很快你就可以通过PowerShell和托管库来配置它了。
答案 2 :(得分:3)
此功能目前尚未得到官方支持,尽管它存在基础设施。我们正在努力在不久的将来为它提供支持。