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

azurerm_sql_database StatusCode=404 -- Original Error: autorest/azure: Service returned an error. #6157

Closed
rohrerb opened this issue Mar 18, 2020 · 4 comments · Fixed by #6233
Labels
bug service/mssql Microsoft SQL Server
Milestone

Comments

@rohrerb
Copy link
Contributor

rohrerb commented Mar 18, 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

Terraform v0.12.23

  • provider.azurerm v2.1.0
  • provider.random v2.2.1

Affected Resource(s)

  • azurerm_sql_database

Terraform Configuration Files

provider "azurerm" {
  version = "=2.1.0"

  features {}
}

locals {
  dbs              = ["db1"]
  deploy_secondary = false

  primary_location   = "usgovvirginia"
}

resource "azurerm_resource_group" "group" {
  name     = "db_error"
  location = local.primary_location
}

resource "random_password" "sql_server_password" {
  for_each = toset(local.dbs)
  length   = 32
  special  = true
}

resource "azurerm_sql_server" "sqlserver" {
  for_each                     = toset(local.dbs)
  name                         = format("%s-sqlserver-%s", lower("xyzenv"), lower(each.key))
  resource_group_name          = azurerm_resource_group.group.name
  location                     = azurerm_resource_group.group.location
  version                      = "12.0"
  administrator_login          = format("%s_%s", each.key, "admin")
  administrator_login_password = random_password.sql_server_password[each.key].result
  provisioner "local-exec" {
    command = format("echo fully qualified sql server domain name %s with creds of '%s'", self.fully_qualified_domain_name, random_password.sql_server_password[each.key].result)
  }
}

resource "azurerm_sql_database" "db" {
  for_each = toset(local.dbs)

  name                             = each.key
  resource_group_name              = azurerm_resource_group.group.name
  location                         = azurerm_resource_group.group.location
  server_name                      = azurerm_sql_server.sqlserver[each.key].name
  edition                          = "Standard"
  requested_service_objective_name = "S0"  
}

Debug Output

Expected Behavior

Apply should succeed.

Actual Behavior

Error: Error reading SQL Server xyzenv-sqlserver-db1 Blob Auditing Policies: sql.ExtendedServerBlobAuditingPoliciesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="SubscriptionNotFound" Message="The subscription '75406810-xxxx-xxxx-xxxx-e9027e0a0a45' could not be found."

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

  • New provider update breaks the azurerm_sql_database resource in USGOV.
  • Works fine with provider 2.0.0
@ttfjustin
Copy link

ttfjustin commented Mar 20, 2020

Also fails terraform plan, seeing the same here.

Unsure if it's worth mentioning, but the object I am attempting to plan against is an existing database. Also fails on public cloud and AzureChinaCloud. Also fails using provider.azurerm v2.2.0.

I'm unable to rollback to 2.0.0 due to other bugs, do this was a direct upgrade from 1.43.

@msyinjie
Copy link

msyinjie commented Mar 22, 2020

also failed in Azure Devops and using the provider 2.2.0 create Azure sql server, the error info as below:

Error issuing create/update request for SQL Server "xxx-sql-01" Blob Auditing Policies(Resource Group "xxx-db-rg"): sql.ExtendedServerBlobAuditingPoliciesClient#CreateOrUpdate: Failure sending request: StatusCode=404 -- Original Error: Code="SubscriptionNotFound" Message="The subscription '263f665e-xxxxxx-c7653141' could not be found.

code as below:
`

extended_auditing_policy {
storage_endpoint                        = "${data.azurerm_storage_account.storageaccount.primary_blob_endpoint}"
storage_account_access_key              = "${data.azurerm_storage_account.storageaccount.primary_access_key}"
storage_account_access_key_is_secondary = false
retention_in_days                       = 7

`
rollback to 2.0.0 provider and delete the extended_auditing_policy code block, it works fine.

provider "azurerm" {
  version = "=2.0.0"

  features {}
}

maybe need define the storage account subscription id.
https://docs.microsoft.com/en-us/rest/api/sql/server%20extended%20auditing%20settings/createorupdate#extendedserverblobauditingpolicy

@ghost
Copy link

ghost commented Mar 27, 2020

This has been released in version 2.3.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.3.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Apr 23, 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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 23, 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