hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.45k stars 4.53k forks source link

detaching api tag "Api Tag" #26386

Open vishalholla27 opened 1 week ago

vishalholla27 commented 1 week ago

Is there an existing issue for this?

Community Note

detaching api tag "Api Tag (Subscription: \"*\"\nResource Group Name: \"****\"\nService Name: \"APIM\"\nApi: \"AIS-APIM-DEV\"\nTag: \"AppComplexity-Medium\")": unexpected status 400 (400 Bad Request) with error: ValidationError: Invalid payload format. Contract should have 'properties' specified

Terraform Version

latest

AzureRM Provider Version

3.108

Affected Resource(s)/Data Source(s)

azurerm

Terraform Configuration Files

detaching api tag "Api Tag (Subscription: \"***\"\nResource Group Name: \"**********\"\nService Name: \"APIM\"\nApi: \"AIS-APIM-DEV\"\nTag: \"AppComplexity-Medium\")": unexpected status 400 (400 Bad Request) with error: ValidationError: Invalid payload format.  Contract should have 'properties' specified

Debug Output/Panic Output

detaching api tag "Api Tag (Subscription: \"***\"\nResource Group Name: \"**********\"\nService Name: \"APIM\"\nApi: \"AIS-APIM-DEV\"\nTag: \"AppComplexity-Medium\")": unexpected status 400 (400 Bad Request) with error: ValidationError: Invalid payload format.  Contract should have 'properties' specified

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

heller-tobias commented 1 week ago

This issue can be reproduced by calling the Azure REST API with the same parameters: https://learn.microsoft.com/en-us/rest/api/apimanagement/tag/detach-from-api?view=rest-apimanagement-2022-08-01&tabs=HTTP So I assume it is not an issue with the provider itself.

landintrees commented 1 week ago

We were having the same issue deleting some API resources today (azurerm_api_management_api) and getting the exact same error on most of our deployments but not all. This led us to try re-running the TF apply multiple times which did eventually delete the resources. Possible instability/canary rollout on Azure's end?

matt-lethargic commented 1 week ago

So does anyone have an idea on how to follow this up??

heller-tobias commented 1 week ago

So does anyone have an idea on how to follow this up??

I have created a support request with Azure itself. I have not heard anything regarding ETA yet.

vishalholla27 commented 1 week ago

Currently to ignore this issue, i have added lifecycle ignore in terraform module for TAGS lifecycle{ ignore_changes= [api_id] }

this code in resource "azurerm_api_management_api_tags" "api_tag"

tombuildsstuff commented 1 week ago

@mybayern1974 since you've labelled this, have you spoke with the Service Team about this one? Looks to be an API regression

rgembalik commented 1 week ago

We have a similar error message during api removal

lukdz commented 1 week ago

Looks to be an issue on Microsoft side: image

API Management - Intermittent 400 Level Erros when performing delete requests
Active: An Azure service issue (Tracking ID WK7Z-9ZZ) impacted resources in your subscription.
Starting on the 7 Jun 2024, you have been identified as a customer using API Management Service who may see 400 level bad request errors when trying to performing the delete operation. Retries may be successful

Please use the links below to view the latest information about the issue in Azure Service Health and be sure to [create a Service Health alert](https://learn.microsoft.com/azure/azure-monitor/platform/alerts-activity-log-service-notifications?WT.mc_id=Portal-Microsoft_Azure_Support) to be automatically notified should an Azure event affect you.
mybayern1974 commented 1 week ago

@mybayern1974 since you've labelled this, have you spoke with the Service Team about this one? Looks to be an API regression

Not yet, since I noticed there is already ticket filed to the target service team, so would like to see first how that progress would be like.

J0F3 commented 1 week ago

It seems that Azure has fixed the issue now: https://app.azure.com/h/WK7Z-9ZZ/e5ec0f image

@tombuildsstuff The azurerm provider made this problem unfortunately worse than it actually was because of this bug: https://github.com/hashicorp/terraform-provider-azurerm/issues/24705 (I do also not know why this issue is now closed even doe it has not resolved yet!?).

For existing deployment, whiteout any actual changes the Azure Bug would actually not had any impact. But because of https://github.com/hashicorp/terraform-provider-azurerm/issues/24705 it hat impact for every deployment even when absolutely nothing has changed or would have to be deleted. 😢

sinbai commented 6 days ago

Currently, I am unable to reproduce the above error using the following tf config, which creates and then deletes the azurerm_api_management_api_tag (three times). If anyone could also reroduce the issue, is it possible to provide the tf config and repro steps to help with reproducing and troubleshotting?


provider "azurerm" {
  version = "3.108.0"
  features {}
}

resource "azurerm_resource_group" "test" {
  name     = "acctestRG-0625-26386"
  location = "eastus"
}

resource "azurerm_api_management" "test" {
  name                = "acctestAM-0625-26386"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name
  publisher_name      = "pub1"
  publisher_email     = "pub1@email.com"

  sku_name = "Consumption_0"
}

resource "azurerm_api_management_api" "test" {
  name                = "acctestapi-0625-26386"
  resource_group_name = azurerm_resource_group.test.name
  api_management_name = azurerm_api_management.test.name
  display_name        = "api1"
  path                = "api1"
  protocols           = ["https"]
  revision            = "1"
}

resource "azurerm_api_management_tag" "test" {
  api_management_id = azurerm_api_management.test.id
  name              = "acctest-Tag-0625-26386"
}

resource "azurerm_api_management_api_tag" "test" {
  api_id = azurerm_api_management_api.test.id
  name   = "acctest-Tag-0625-26386"
}
lukdz commented 6 days ago

@sinbai Looking at prevision comment and my own experience with APIM, I would say that Azure fixed the issue (at least for now).

alexwiese commented 5 days ago

@tombuildsstuff The azurerm provider made this problem unfortunately worse than it actually was because of this bug: #24705 (I do also not know why this issue is now closed even doe it has not resolved yet!?).

For existing deployment, whiteout any actual changes the Azure Bug would actually not had any impact. But because of #24705 it hat impact for every deployment even when absolutely nothing has changed or would have to be deleted. 😢

For now we workaround like so, awaiting the fix in azurerm 4.0.0

api_id = split(";", azurerm_api_management_api.example.id)[0]