Terraform-provider-azurerm: azurerm_cosmosdb_account fails with documentdb.DatabaseAccountsClient#CheckNameExists: Failure responding to request: StatusCode=500

Created on 2 Jun 2020  ·  17Comments  ·  Source: terraform-providers/terraform-provider-azurerm

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.9
azurerm v2.10.0

Affected Resource(s)

  • azurerm_cosmosdb_account

Terraform Configuration Files

resource "random_integer" "ri" {
  min = 10000
  max = 99999
}

resource "azurerm_cosmosdb_account" "this" {
  name                = "${local.location}${local.subscription}xxx"
  location            = "${local.location}"
  resource_group_name = "${local.location}-${local.subscription}-${local.owner}-rg"
  offer_type          = "Standard"
  kind                = "MongoDB"

  enable_automatic_failover = true

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }

  geo_location {
    location          = var.db_failover_location
    failover_priority = 1
  }

  geo_location {
    prefix            = "${local.location}${local.subscription}xxx-${random_integer.ri.result}-customid"
    location          = "${local.location}"
    failover_priority = 0
  }

  tags = "${module.tag.tags}"

}

Debug Output

Panic Output

Expected Behavior

Provider creates CosmosDB account

Actual Behavior

Provider does not create CosmosDB account and fails with the following message.

Error: Error checking if CosmosDB Account "xxx" already exists (Resource Group "xxx"): documentdb.DatabaseAccountsClient#CheckNameExists: Failure responding to request: StatusCode=500 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF

  on cosmosdb.tf line 1, in resource "azurerm_cosmosdb_account" "this":
   1: resource "azurerm_cosmosdb_account" "this" {

Steps to Reproduce

  1. terraform apply

Important Factoids

Running in Azure Westeurope

References

  • #3739
serviccosmosdb upstream-microsoft

Most helpful comment

We've deployed the fix for this and the issue is resolved.

All 17 comments

This started happening for me today. Started with a completely clean slate using the examples pulled from the documentation. This was in North Europe. I tried deploying to UK South to see if it was a region thing but seems to fail regardless.

Terraform:

resource "azurerm_cosmosdb_account" "db" {
  name = "my-cmdb-resource-name"
  location = "North Europe"
  resource_group_name = azurerm_resource_group.main.name
  offer_type = "Standard"
  kind = "GlobalDocumentDB"
  tags = local.tags

  consistency_policy {
    consistency_level = "Session"
  }

  geo_location {
    location = "North Europe"
    failover_priority = 0
  }
}

Terraform version: 0.12.26
AzureRM: 2.11.0

I am using TF 0.12.26 with AzureRM 2.10 and experiancing same issue --- fails on previous success IaC executions.

Here's the output I'm getting, might open up a support case with Microsoft -- I doubt this is an azurerm provider issue since it's throwing a 500 error. Not much terraform can do about it.

Our resources are also in West Europe like others above.

Edit: I've opened a support case with Microsoft on this -- Request 120060224009612

2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: [DEBUG] AzureRM Request: 
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: HEAD /providers/Microsoft.DocumentDB/databaseAccountNames/ads-paas-dev-gwe-cosmos-74364?api-version=2015-04-08 HTTP/1.1
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Host: management.azure.com
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: User-Agent: Go/go1.14.2 (amd64-windows) go-autorest/v14.0.0 Azure-SDK-For-Go/v41.2.0 documentdb/2015-04-08 HashiCorp Terraform/0.12.26 (+https://www.terraform.io) Terraform Plugin SDK/1.6.0 terraform-provider-azurerm/2.10.0 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Correlation-Request-Id: 0bb0e0fd-da9f-6764-572a-0458fd88612a
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe:
2020-06-02T16:51:55.462-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe:
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: [DEBUG] AzureRM Response for https://management.azure.com/providers/Microsoft.DocumentDB/databaseAccountNames/ads-paas-dev-gwe-cosmos-74364?api-version=2015-04-08:
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: HTTP/2.0 500 Internal Server Error
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Content-Length: 323
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Cache-Control: no-store, no-cache
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Date: Tue, 02 Jun 2020 21:51:38 GMT
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Pragma: no-cache
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Server: Microsoft-HTTPAPI/2.0
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: Strict-Transport-Security: max-age=31536000; includeSubDomains
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Content-Type-Options: nosniff
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Correlation-Request-Id: 0bb0e0fd-da9f-6764-572a-0458fd88612a
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Failure-Cause: service
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Ratelimit-Remaining-Tenant-Reads: 11998
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Request-Id: 55c72b0c-e78b-467b-b270-547b440fb4d6
2020-06-02T16:51:55.734-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.10.0_x5.exe: X-Ms-Routing-Request-Id: CANADAEAST:20200602T215139Z:55c72b0c-e78b-467b-b270-547b440fb4d6

Microsoft has indicated it might be a known issue.

i am getting same error.

Terraform v0.12.26
provider.azurerm v2.3.0

I am also getting the same issues..

Terraform v0.12.24
provider.azurerm v2.8.0 v2.9.0 v2.10.0 v.2.11.0 v2.12.0 (all these versions)

Was working until 1am (UST) 2nd June 2020, suddenly stopped working there after.

Seeing the same thing in Australia Southeast

Seeing this in France Central as well.
Terraform v0.12.26

  • provider.azurerm v2.12.0

I have raised a Microsoft support request and the Cosmos product team are apparently looking into this as a possible Azure side issue.

Same issue in Central US and West US

Error checking if CosmosDB Account "" already exists
documentdb.DatabaseAccountsClient#CheckNameExists: Failure responding to request: StatusCode=500

FYI. I've been able to get the CosmosDB account by downgrading to azurerm v1.31.0 (which ignores the 500 error). It's not a pretty workaround but it works for the time being.

Upstream issue raised: https://github.com/Azure/azure-sdk-for-go/issues/9891
We'll prepare a similar workaround for the 500 status.

We have identified the root cause for this and are actively working on a hot fix to the issue. ETA should be tomorrow.

Thanks.

We've deployed the fix for this and the issue is resolved.

As suggested by the above link, I have tested the hotfix of azurerm version 2.12.0, and it is working.

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

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!

Was this page helpful?
0 / 5 - 0 ratings