Terraform Azure 无法创建数据库

Terraform Azure fails to create Database

我正在使用 terraform 2.33.0(我也测试了 2.90.0)创建一个 sql 服务器,然后创建一个数据库

今天我开始收到以下错误:

Error waiting on create/update future for SQL Database "x" (Resource Group "y", Server "z"): Code="45157" Message="Server 'z' is busy with another operation. Please try your operation later.

这次失败后,我可以在门户中正常创建 sql 数据库。

有人见过这个问题或类似的问题吗?

SQL服务器是这样创建的:

resource "azurerm_sql_server" "tenant_sql" {
  name                         = "fakename"
  resource_group_name          = azurerm_resource_group.tenant_rg.name
  location                     = var.location
  version                      = "12.0"
  administrator_login          = var.sql_server_admin_login
  administrator_login_password = random_password.sql_server_admin_password.result

   tags = {
        Application = "blah"
      Tenant = var.tenant
      CustomerId = var.customer_id
      Environment = var.environment
    }
}

数据库是这样创建的

resource "azurerm_sql_database" "tenant_sqldb" {
  name                             = "x"
  resource_group_name              = azurerm_resource_group.tenant_rg.name
  location                         =  var.location
  server_name                      = "fakename"
  create_mode                      = "Default"
  edition                          = var.database_is_premium == true ? "Premium" : "Standard"
  requested_service_objective_name = var.database_is_premium == true ? "P4" : "S1"
  max_size_bytes = 268435456000
   tags = {
      Application = "bah"
      Tenant      = var.tenant
      CustomerId  = var.customer_id
      Environment = var.environment
    }
}

这一切作为一个脚本执行!

值得注意的是,azurem_sql_database 已被弃用,因此可能 RM API 行为已经改变,azurem_sql_database 并未考虑到这一点。

通过从已弃用的 azurerm_sql_server 移至 azurerm_mssql_server 和 azurerm_sql_database 移至 azurerm_mssql_database

来解决