如何激活使用二头肌自动调整创建和删除索引?
我搜索过,二头肌中似乎有这个资源
Microsoft.Sql/servers/databases/automaticTuning
,但我没有仅激活创建和删除索引的选项。
更新1: 这是我的二头肌代码:
resource sqlServer 'Microsoft.Sql/servers@2022-02-01-preview' = {
name: '${appName}-${environment}-sql'
location: location
properties: {
administratorLogin: '${environment}-admin'
administratorLoginPassword: sqlPassword
minimalTlsVersion: '1.2'
restrictOutboundNetworkAccess: 'Disabled'
publicNetworkAccess: publicNetworkAccess ? 'Enabled' : 'Disabled'
}
identity: {
type: 'SystemAssigned'
}
}
resource sqlServer 'Microsoft.Sql/servers@2022-02-01-preview' existing = {
name: sqlServerName
}
resource sqlServerDatabase 'Microsoft.Sql/servers/databases@2022-02-01-preview' = {
parent: sqlServer
name: '${appName}-${environmentName}-db-${dbName}'
location: location
sku: environmentSettings[toLower(environmentName)].sku
}
Microsoft.Sql/servers/advisors
设置自动调整创建和删除索引。
此资源的功能仅适用于引用最新版本中的现有资源。如果您想部署新资源,则需要使用旧的 API 版本:
2014-04-01
,详细信息如下。
主要.二头肌:
param servername string = 'myserverj'
@minLength(1)
param servernameAdminLogin string = 'jahnaviadmin'
param servernameAdminLoginPassword string = 'xxxx'
resource server 'Microsoft.Sql/servers@2023-08-01-preview' = {
name: servername
location: 'West Europe'
properties: {
administratorLogin: servernameAdminLogin
administratorLoginPassword: servernameAdminLoginPassword
version: '12.0'
}
}
resource ForceLast 'Microsoft.Sql/servers/advisors@2014-04-01' = {
parent: server
name: 'ForceLastGoodPlan'
properties: {
autoExecuteValue: 'Enabled'
}
}
resource Create 'Microsoft.Sql/servers/advisors@2014-04-01' = {
parent: server
name: 'CreateIndex'
properties: {
autoExecuteValue: 'Enabled'
}
}
resource Drop 'Microsoft.Sql/servers/advisors@2014-04-01' = {
parent: server
name: 'DropIndex'
properties: {
autoExecuteValue: 'Enabled'
}
}
部署成功:
您也可以参考此SO使用ARM模板启用它。