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

使用Terraform创建Azure MySQL灵活服务器时SKU名称报错求助

解决Azure MySQL Flexible Server Terraform部署的SKU错误

问题原因

你使用的sku_name = "Standard_B1ms"不符合Azure MySQL Flexible Server的SKU命名规范。Azure MySQL Flexible Server的SKU命名格式与旧版单服务器不同,必须包含层级前缀。

正确的SKU格式

Azure MySQL Flexible Server的SKU遵循以下结构:
{层级}_{硬件系列}_{实例大小}

其中:

  • 层级:分为三类
    • GP:通用用途(General Purpose)
    • BC:突发性能(Burstable)
    • MO:内存优化(Memory Optimized)
  • 硬件系列:通常为Standard
  • 实例大小:如B1ms、D2s_v3、E2s_v3等

有效SKU示例

  • 突发性能型(匹配你原本想要的B1ms实例):BC_Standard_B1ms
  • 通用用途型:GP_Standard_D2s_v3
  • 内存优化型:MO_Standard_E2s_v3

修正后的Terraform代码

将sku_name替换为有效取值即可,以下是修正后的完整代码:

resource "azurerm_mysql_flexible_server" "flexible_mysql" {
  name                   = "kjghfbdretyhmysql"
  resource_group_name    = "CYARC-TF-DEV-RG-EA-001"
  location               = "East US"
  version                = "8.0.21"
  administrator_login    = "adminuser"
  administrator_password = "Internet@123"
  backup_retention_days  = 7 # 1到35天  
  geo_redundant_backup_enabled   = false  
  sku_name               = "BC_Standard_B1ms" # 修正为有效SKU
  storage {
    auto_grow_enabled    = true
    iops                 = 640
    size_gb              = 20
  }
}

验证目标区域可用SKU

若需确认指定区域的所有有效SKU,可执行Azure CLI命令:

az mysql flexible-server list-skus --location EastUS

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 04:52:38