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

CosmosDB throws Unknown service error #241

Closed
TsuyoshiUshio opened this issue Aug 12, 2017 · 11 comments · Fixed by #1464
Closed

CosmosDB throws Unknown service error #241

TsuyoshiUshio opened this issue Aug 12, 2017 · 11 comments · Fixed by #1464
Assignees
Milestone

Comments

@TsuyoshiUshio
Copy link
Contributor

Hi there,

I encounter the error when I deploy Cosmos DB. It might be very basic configuration. However, it says Unknow service error I have no clue to fix this.

Terraform Version

Terraform v0.10.0

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_cosmosdb_account

Terraform Configuration Files

# Service Principle
variable "subscription_id" {
}

variable "client_id" {
}

variable "client_secret" {
}

variable "tenant_id" {
}

# Resource Group

variable "resource_group" {

}

variable "location" {

}

variable "environment" {

}

variable "cosmos_db_name" {
}


provider "azurerm" {
  # Service Principle
  subscription_id = "${var.subscription_id}"
  client_id       = "${var.client_id}"
  client_secret   = "${var.client_secret}"
  tenant_id       = "${var.tenant_id}"
}

# Create a resource group
resource "azurerm_resource_group" "test" {
  name     = "${var.resource_group}"
  location = "${var.location}"
    tags {
        environment = "${var.environment}"
    }
}

# Cosmos DB

resource "azurerm_cosmosdb_account" "test" {
   name                =   "${var.cosmos_db_name}"
   location            =   "${azurerm_resource_group.test.location}"
   resource_group_name =   "${azurerm_resource_group.test.name}"
   offer_type          =   "Standard"
   consistency_policy {
       consistency_level = "Session"
   }

   failover_policy {
       location        =   "East US"
       priority        =   0
   }

   tags {
       environment = "${var.environment}"
   }
}

Debug Output

Error

Error: autorest/azure: Service returned an error. Status=400 Code="Unknown" Message="Unknown service error"

Expected Behavior

It should be create a CosmosDB (DocumentDB) instance on Azure

Actual Behavior

The error cause. we can see empty Resource Group.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a terraform.tfvar according to the your environment
  2. terraform apply

References

nothing

@tombuildsstuff
Copy link
Member

Hey @TsuyoshiUshio

Thanks for opening this issue

So that we can look into this further would it be possible to know which Region you're attempting to deploy the CosmosDB instance into (i.e. the value of var.location)?

Thanks!

@maniSbindra
Copy link
Contributor

maniSbindra commented Aug 14, 2017

@tombuildsstuff I tried running the sample provided by @TsuyoshiUshio and got the same error"Message=Unknown service error" for location values "westus" and "centralus". I did not try for any other locations

@tombuildsstuff
Copy link
Member

Hey @maniSbindra / @TsuyoshiUshio

Using the following configuration I'm able to successfully deploy a CosmosDB instance - would you mind confirming if this works for you?

In addition - have you deployed a CosmosDB/DocumentDB Account into this Azure Subscription + Region previously? I'm trying to isolate if this is related to a missing Resource Provider registration (which will be added into the next release of the AzureRM Provider) or if this is specific to these regions?

variable "environment" {
  default = "test"
}

resource "azurerm_resource_group" "test" {
  name     = "tharvey-dev"
  location = "west europe"
    tags {
        environment = "${var.environment}"
    }
}

resource "azurerm_cosmosdb_account" "test" {
   name                =   "tharvey-cosmos"
   location            =   "${azurerm_resource_group.test.location}"
   resource_group_name =   "${azurerm_resource_group.test.name}"
   offer_type          =   "Standard"
   consistency_policy {
       consistency_level = "Session"
   }

   failover_policy {
       location        =   "East US"
       priority        =   0
   }

   tags {
       environment = "${var.environment}"
   }
}

Thanks!

@maniSbindra
Copy link
Contributor

@tombuildsstuff I need to double check this again, but I created a Azure cosmosdb account from the portal in centralus, after doing this my terraform apply failed with regions westus, eastus (same unknown service error), but succeeded for location centralus.

@TsuyoshiUshio
Copy link
Contributor Author

@tombuildsstuff I tried my terraform.tf on West US. Today, I tried your terraform.tf. It works both on west europe and west us. Also, it works on my script as well. Hmm. Something has changed on the Azure side? Anyway, thank you for your help.

@tombuildsstuff
Copy link
Member

Hey @TsuyoshiUshio

Something has changed on the Azure side?

I'm unaware of any changes there, but possibly - I think it's more likely this is the missing Resource Provider registration which will be fixed in the next release. Regardless it's good to hear that this is now working again :)

@maniSbindra @TsuyoshiUshio out of interest, have you been using CosmosDB/DocumentDB back when it was available in Preview/less regions than today? I'm wondering if this is the Resource Provider registration being exposed in manor I've not seen before. If you've got the Azure CLI 2.0 installed, would you mind showing me the output of this command?

$ az provider show --namespace "Microsoft.DocumentDB"

which I'm hoping should show something similar too:

{
  "id": "/subscriptions/XXXX/providers/Microsoft.DocumentDB",
  "namespace": "Microsoft.DocumentDB",
  "registrationState": "Registered",
  "resourceTypes": [
    {
      "aliases": null,
      "apiVersions": [
        "2016-03-31",
        "2016-03-19",
        "2015-11-06",
        "2015-04-08",
        "2014-04-01"
      ],
      "locations": [
        "Australia East",
        "Australia Southeast",
        "Canada Central",
        "Canada East",
        "Central India",
        "Central US",
        "East Asia",
...

Thanks!

@maniSbindra
Copy link
Contributor

@tombuildsstuff details as requested

{
    "id": "/subscriptions/XXXXXX/providers/Microsoft.DocumentDB",
    "namespace": "Microsoft.DocumentDB",
    "registrationState": "Registered",
    "resourceTypes": [
        {
            "aliases": null,
            "apiVersions": [
                "2016-03-31",
                "2016-03-19",
                "2015-11-06",
                "2015-04-08",
                "2014-04-01"
            ],
            "locations": [
                "Australia East",
                "Australia Southeast",
                "Canada Central",
                "Canada East",
                "Central India",
                "Central US",
                "East Asia",
                "East US",
                "East US 2",
                "Japan East",
                "Japan West",
                "North Central US",
                "North Europe",
                "South Central US",
                "South India",
                "Southeast Asia",
                "West Central US",
                "West Europe",
                "West India",
                "West US",
                "West US 2",
                "UK West",
                "UK South",
                "Brazil South",
                "Korea South",
                "Korea Central"
            ],
            "properties": null,
            "resourceType": "databaseAccounts"
        },
        {
            "aliases": null,
            "apiVersions": [
                "2016-03-31",
                "2016-03-19",
                "2015-11-06",
                "2015-04-08",
                "2014-04-01"
            ],
            "locations": [
                "Australia East",
                "Australia Southeast",
                "Canada Central",
                "Canada East",
                "Central India",
                "Central US",
                "East Asia",
                "East US",
                "East US 2",
                "Japan East",
                "Japan West",
                "North Central US",
                "North Europe",
                "South Central US",
                "South India",
                "Southeast Asia",
                "West Central US",
                "West Europe",
                "West India",
                "West US",
                "West US 2",
                "UK West",
                "UK South",
                "Brazil South",
                "Korea South",
                "Korea Central"
            ],
            "properties": null,
            "resourceType": "databaseAccountNames"
        },
        {
            "aliases": null,
            "apiVersions": [
                "2016-03-31",
                "2016-03-19",
                "2015-11-06",
                "2015-04-08",
                "2014-04-01"
            ],
            "locations": [
                "Australia East",
                "Australia Southeast",
                "Canada Central",
                "Canada East",
                "Central India",
                "Central US",
                "East Asia",
                "East US",
                "East US 2",
                "Japan East",
                "Japan West",
                "North Central US",
                "North Europe",
                "South Central US",
                "South India",
                "Southeast Asia",
                "West Central US",
                "West Europe",
                "West India",
                "West US",
                "West US 2",
                "UK West",
                "UK South",
                "Brazil South",
                "Korea South",
                "Korea Central"
            ],
            "properties": null,
            "resourceType": "operations"
        }
    ]
}

@TsuyoshiUshio
Copy link
Contributor Author

Also, I realize one difference between last time and now. I usually stay in Japan. However, at that time, I was staying in Redmond.

$ az provider show --namespace "Microsoft.DocumentDB"
{
  "id": "/subscriptions/MYSUBSCRIPTION/providers/Microsoft.DocumentDB",
  "namespace": "Microsoft.DocumentDB",
  "registrationState": "Registered",
  "resourceTypes": [
    {
      "aliases": null,
      "apiVersions": [
        "2016-03-31",
        "2016-03-19",
        "2015-11-06",
        "2015-04-08",
        "2014-04-01"
      ],
      "locations": [
        "Australia East",
        "Australia Southeast",
        "Canada Central",
        "Canada East",
        "Central India",
        "Central US",
        "East Asia",
        "East US",
        "East US 2",
        "Japan East",
        "Japan West",
        "North Central US",
        "North Europe",
        "South Central US",
        "South India",
        "Southeast Asia",
        "West Central US",
        "West Europe",
        "West India",
        "West US",
        "West US 2",
        "UK West",
        "UK South",
        "Brazil South",
        "Korea South",
        "Korea Central"
      ],
      "properties": null,
      "resourceType": "databaseAccounts"
    },
    {
      "aliases": null,
      "apiVersions": [
        "2016-03-31",
        "2016-03-19",
        "2015-11-06",
        "2015-04-08",
        "2014-04-01"
      ],
      "locations": [
        "Australia East",
        "Australia Southeast",
        "Canada Central",
        "Canada East",
        "Central India",
        "Central US",
        "East Asia",
        "East US",
        "East US 2",
        "Japan East",
        "Japan West",
        "North Central US",
        "North Europe",
        "South Central US",
        "South India",
        "Southeast Asia",
        "West Central US",
        "West Europe",
        "West India",
        "West US",
        "West US 2",
        "UK West",
        "UK South",
        "Brazil South",
        "Korea South",
        "Korea Central"
      ],
      "properties": null,
      "resourceType": "databaseAccountNames"
    },
    {
      "aliases": null,
      "apiVersions": [
        "2016-03-31",
        "2016-03-19",
        "2015-11-06",
        "2015-04-08",
        "2014-04-01"
      ],
      "locations": [
        "Australia East",
        "Australia Southeast",
        "Canada Central",
        "Canada East",
        "Central India",
        "Central US",
        "East Asia",
        "East US",
        "East US 2",
        "Japan East",
        "Japan West",
        "North Central US",
        "North Europe",
        "South Central US",
        "South India",
        "Southeast Asia",
        "West Central US",
        "West Europe",
        "West India",
        "West US",
        "West US 2",
        "UK West",
        "UK South",
        "Brazil South",
        "Korea South",
        "Korea Central"
      ],
      "properties": null,
      "resourceType": "operations"
    }
  ]
}

@StuartGreenhall
Copy link

Hi, We've been having the same issue and then realised that the db name need to be globally unique. which fixed the error for us.

@achandmsft achandmsft added the M3 label Apr 26, 2018
@katbyte katbyte self-assigned this May 17, 2018
@katbyte katbyte added this to the 1.6.0 milestone May 17, 2018
@tombuildsstuff
Copy link
Member

This is likely that the name being used is in use - we should change this to check if the name exists

@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants