激活创建索引和删除索引以自动调整sql数据库的二头肌

问题描述 投票:0回答:1

如何激活使用二头肌自动调整创建和删除索引?

我搜索过,二头肌中似乎有这个资源

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
}
azure azure-bicep
1个回答
0
投票

可以使用二头肌中的资源提供者

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'
  }
}

部署成功:

enter image description here

您也可以参考此SO使用ARM模板启用它。

© www.soinside.com 2019 - 2024. All rights reserved.