0

Im using terraform 2.33.0 (I tested 2.90.0 too ) to create a sql server and then create a database

Today Ive started getting the following error:

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.

I can create the sql database in the portal fine after this failure.

Has anybody seen this issue or anything like it?

The SQL Server is created like this:

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

The db is created like this

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

This all executes as one script!

Its worth noting that azurem_sql_database is deprecated so perhaps the RM API behaviour has changed and azurem_sql_database isnt accounting for this.

4
  • 1
    Please add formatting to the question to make it easily readable. Commented Jan 27, 2022 at 15:10
  • Was the SQL server z fully created before the database creation failed? Commented Jan 27, 2022 at 16:21
  • I reckon it wasnt. What Im suprised at is that the Azure plugin for Terraform should manage this since it was the same terraform script building both. Commented Jan 27, 2022 at 21:38
  • I upgraded to latest (at the time) which is 2.93.1 of the AzureRM (which requires terraform 0.12.31 minimum) and this didnt solved the problem. Commented Feb 8, 2022 at 10:36

1 Answer 1

1

Solved by moving away from the deprecated azurerm_sql_server to azurerm_mssql_server and azurerm_sql_database to azurerm_mssql_database

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.