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

Failed to create Cognitive Service Account when qname_runtime_endpoint is not set #6343

Closed
johejo opened this issue Apr 3, 2020 · 8 comments · Fixed by #7916
Closed

Failed to create Cognitive Service Account when qname_runtime_endpoint is not set #6343

johejo opened this issue Apr 3, 2020 · 8 comments · Fixed by #7916

Comments

@johejo
Copy link
Contributor

johejo commented Apr 3, 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

v2.3.0 or newer

Affected Resource(s)

  • azurerm_cognitive_account

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
resource "azurerm_cognitive_account" "cognitive_service" {
  name                = var.cognitive_service_name
  resource_group_name = var.resource_group_name
  location            = var.location
  kind                = "CognitiveServices"
  sku_name            = "S0"
}

Debug Output

Panic Output

Expected Behavior

Successfully create cognitive account.

Actual Behavior

azurerm_cognitive_account.cognitive_service: Creating...

Error: Error creating Cognitive Services Account ***: cognitiveservices.AccountsClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ApiPropertiesInvalid" Message="The given 'apiProperties' '{\r\n  \"qnaRuntimeEndpoint\": \"\"\r\n}' is invalid. Validation errors: Property 'qnaRuntimeEndpoint' has not been defined and the schema does not allow additional properties. Path 'apiProperties.qnaRuntimeEndpoint'."

  on main.tf line ***, in resource "azurerm_cognitive_account" "cognitive_service":
 ***: resource "azurerm_cognitive_account" "cognitive_service" {

https://github.com/terraform-providers/terraform-provider-azurerm/blob/c916aa6db4142add1760a9b39bc668eb8b1dfcde/azurerm/internal/services/cognitive/resource_arm_cognitive_account.go#L156-L166

Caused by #5778.
The 'qnaRuntimeEndpoint' type is *string.
If we assign a "" using utils.String into 'qnaRuntimeEndpoint', we will get a "" in json by marshaling.
We should use d.GetOk("qname_runtime_endpoint") and need to check if exists.
https://github.com/Azure/azure-sdk-for-go/blob/b7d185716507a401293b9f6c303f6e9798c4cb1b/services/cognitiveservices/mgmt/2017-04-18/cognitiveservices/models.go#L258-L268

Steps to Reproduce

  1. terraform apply

Important Factoids

References

johejo added a commit to johejo/terraform-provider-azurerm that referenced this issue Apr 3, 2020
johejo added a commit to johejo/terraform-provider-azurerm that referenced this issue Apr 4, 2020
@devedse
Copy link

devedse commented Apr 10, 2020

Hi all, I'm also running into this issue and was wondering what the status since the pull requests confuses me.

I assume that by writing tests @johejo figured out that when we don't pass the qna_runtime_endpoint, terraform doesn't include this in the API.

If that's the case, can we maybe try to simulate the API call directly and see if we get the same issue?

@katbyte
Copy link
Collaborator

katbyte commented Apr 10, 2020

@devedse - could you share you tf config?

@devedse
Copy link

devedse commented Apr 11, 2020

@katbyte , this is my config:

resource "azurerm_cognitive_account" "cognitiveaccount" {
  name                = "${var.applicationName}-cognitive-${var.environment}"
  resource_group_name = azurerm_resource_group.resourcegroup.name
  location            = azurerm_resource_group.resourcegroup.location
  kind                = "CognitiveServices"

  sku_name = "S0"
}

@georgegil
Copy link

curious, is there a workaround? dummy URL for QNA maker?

@myliyifei
Copy link

myliyifei commented Jul 27, 2020

Terraform (and AzureRM Provider) Version

terraform 0.12.28
azurerm 2.20.0


I encountered the same error when creating the following "Bing.Search.v7" service, even though I added this (qna_runtime_endpoint = null) parameter to the resource module.

kind = "Bing.Search.v7"
sku_name = "F1"
location = "Global"


Error creating Cognitive Services Account "stock-news" (Resource Group "stock"): cognitiveservices.AccountsClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ApiPropertiesInvalid" Message="The given 'apiProperties' '{\r\n "qnaRuntimeEndpoint": ""\r\n}' is invalid. Validation errors: Property 'qnaRuntimeEndpoint' has not been defined and the schema does not allow additional properties. Path 'apiProperties.qnaRuntimeEndpoint'."

@neil-yechenwei
Copy link
Contributor

Thanks for opening this issue. After tested, I found the issue still exists. So I submit a PR to fix this issue.

@ghost
Copy link

ghost commented Jul 31, 2020

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

@ghost
Copy link

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

@ghost ghost locked and limited conversation to collaborators Aug 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.