Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating secondary DB using azurerm_sql_database resource #6269

Closed
rohanvirmani opened this issue Mar 26, 2020 · 4 comments · Fixed by #6402
Closed

Error creating secondary DB using azurerm_sql_database resource #6269

rohanvirmani opened this issue Mar 26, 2020 · 4 comments · Fixed by #6402
Labels
bug service/mssql Microsoft SQL Server
Milestone

Comments

@rohanvirmani
Copy link
Contributor

rohanvirmani commented Mar 26, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

AzureRM 2.1,2.2. TF core 0.12.23

Affected Resource(s)

azurerm_sql_database

Terraform Configuration Files

resource "azurerm_sql_database" "database_secondary" {
  for_each = local.db_secondary_map

  name                = each.value.db_name
  location            = each.value.location
  resource_group_name = var.regional_data_rg[each.value.location].name
  server_name         = azurerm_sql_server.instance[each.value.location].name

  create_mode        = "OnlineSecondary"
  source_database_id = azurerm_sql_database.database_primary[each.value.db_name].id
  edition            = var.sql_pool_tier

  elastic_pool_name = azurerm_mssql_elasticpool.elasticpool[each.value.location].name

  lifecycle {
    prevent_destroy = true
  }
}

Debug Output

Error: Error issuing create/update request for SQL Database "DB" Blob Auditing Policies(SQL Server "sqlsvr"/ Resource Group "resourcegroup"): sql.ExtendedDatabaseBlobAuditingPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BlobAuditingIsNotSupportedOnGeoDr" Message="Blob auditing can be configured on primary databases only."
2020-03-20T17:31:11.5032312Z
2020-03-20T17:31:11.5032410Z on ....\hosting-modules\data\sql\main.tf line 128, in resource "azurerm_sql_database" "database_secondary":
2020-03-20T17:31:11.5032545Z 128: resource "azurerm_sql_database" "database_secondary" {
https://gist.github.com/rohanvirmani/f7d90ba445ce0c6420f4f3796665c8fd

Panic Output

Expected Behavior

Terraform should create/update the SQL databases as normal. This issue happens specifically when using version 2.1 and greater of the AzureRM provider.

Note that we are not defining the extended_auditing_policy block anywhere in our TF code.

Actual Behavior

Steps to Reproduce

Create a new secondary database using terraform using the AzureRM provider (>2.1)

Execute 'terraform apply'

Important Factoids

References

support for the extended_auditing_policy property - added as of AzureRM 2.1.0
#5036

  • #0000
@MarkKharitonov
Copy link

The error is output by the sql server itself. It seems the provider implicitly creates the auditing configuration, even if not specified and communicates it to the sql server, which fails.

@katbyte katbyte added bug service/mssql Microsoft SQL Server labels Mar 28, 2020
@yupwei68
Copy link
Contributor

yupwei68 commented Apr 8, 2020

hi @rohanvirmani, thanks for opening this issue. You could use azurerm_mssql_database temporarily. And we'll continue solving this problem.

@ghost
Copy link

ghost commented May 1, 2020

This has been released in version 2.8.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.8.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented May 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators May 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/mssql Microsoft SQL Server
Projects
None yet
4 participants