You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ARM模板中设置Azure SQL数据库的服务层级

使用ARM模板修改Azure SQL数据库服务层级为General Purpose

要通过ARM模板将Azure SQL数据库的服务层级改为General Purpose,核心是在模板的SQL数据库资源定义中指定正确的sku配置。以下是完整的模板示例及关键说明:

完整ARM模板示例

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serverName": {
      "type": "string",
      "metadata": {
        "description": "目标SQL服务器名称"
      }
    },
    "databaseName": {
      "type": "string",
      "metadata": {
        "description": "要修改的SQL数据库名称"
      }
    },
    "skuCapacity": {
      "type": "int",
      "defaultValue": 2,
      "metadata": {
        "description": "General Purpose层级的vCore数量,可选范围2-80"
      }
    },
    "storageSizeGB": {
      "type": "int",
      "defaultValue": 32,
      "metadata": {
        "description": "数据库存储大小(GB),General Purpose最大支持4TB"
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Sql/servers/databases",
      "apiVersion": "2021-11-01",
      "name": "[concat(parameters('serverName'), '/', parameters('databaseName'))]",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "GP_Gen5", // GP代表General Purpose,Gen5是硬件世代,可根据需求替换为Gen8等
        "tier": "GeneralPurpose", // 这里指定服务层级为通用型
        "capacity": "[parameters('skuCapacity')]",
        "family": "Gen5"
      },
      "properties": {
        "storageAccountType": "GRS",
        "maxSizeBytes": "[mul(parameters('storageSizeGB'), 1073741824)]"
      }
    }
  ]
}

关键配置说明

  • sku.tier:必须设置为GeneralPurpose(注意大小写,Azure ARM模板对该字段大小写敏感),这对应门户中「Compute + Storage」里的「服务层级」选项。
  • sku.name:格式为GP_<硬件世代>,比如GP_Gen5、GP_Gen8,根据你需要的硬件世代选择。
  • sku.capacity:设置vCore的数量,General Purpose层级支持2到80个vCore,可根据业务需求调整。
  • maxSizeBytes:通过storageSizeGB参数计算得到,确保不超过General Purpose层级的存储上限(4TB)。

部署模板的方法

使用Azure CLI

az deployment group create --resource-group <你的资源组名称> --template-file <模板文件路径> --parameters serverName=<SQL服务器名> databaseName=<数据库名>

使用PowerShell

New-AzResourceGroupDeployment -ResourceGroupName <你的资源组名称> -TemplateFile <模板文件路径> -serverName <SQL服务器名> -databaseName <数据库名>

注意事项

  • 修改服务层级会触发数据库的重启,可能会有短暂的停机,请在业务低峰期操作。
  • 如果你的数据库之前使用的是弹性池,需要先将其移出弹性池,再设置独立的General Purpose层级;如果是保留在弹性池中,则需要修改弹性池的sku配置而非单个数据库。
  • 确保你的订阅有足够的配额来支持所选的vCore数量和存储大小。

内容的提问来源于stack exchange,提问作者renathy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 03:21:02