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

azapi_resource - RESPONSE 200: 200 OK │ ERROR CODE: MgmtBadArgument #426

Open
mrchops1024 opened this issue Mar 9, 2024 · 3 comments
Open

Comments

@mrchops1024
Copy link

Provider version: 1.12.1

We initially created a StorageSync SyyncGroup server endpoint with the following code:

resource "azapi_resource" "server_endpoint" {
  type      = "Microsoft.StorageSync/storageSyncServices/syncGroups/serverEndpoints@2022-09-01"
  name      = "${var.share.sync_on_prem.server_endpoint}+${var.share.sync_on_prem.server_path}"
  parent_id = azurerm_storage_sync_group.files_sync_group[var.share.sync_on_prem.server_path].id
  body = jsonencode({
    properties = {
      "cloudTiering"           = var.share.sync_on_prem.cloud_tiering
      "friendlyName"           = var.share.sync_on_prem.server_endpoint
      "initialDownloadPolicy"  = var.share.sync_on_prem.inital_download_policy
      "initialUploadPolicy"    = var.share.sync_on_prem.inital_upload_policy
      "localCacheMode"         = var.share.sync_on_prem.local_cache_mode
      "serverLocalPath"        = var.share.sync_on_prem.server_path
      "serverResourceId"       = var.asf_registered_servers[var.share.sync_on_prem.server_endpoint]
      "volumeFreeSpacePercent" = var.share.sync_on_prem.vol_free_space_percent
      "offlineDataTransfer"    = var.share.sync_on_prem.offline_data_transfer
    }
  })

  depends_on             = [azurerm_storage_sync_group.files_sync_group]

  lifecycle {
    ignore_changes = [
      name
    ]
  }
}

The resource created successfully. We then added response_export_values = ["*"] to the resource and received the following plan:

# azapi_resource.server_endpoint["key"] will be updated in-place
  ~ resource "azapi_resource" "server_endpoint" {
        id                        = "/subscriptions/<subscription id>/resourceGroups/r<resource group name>/providers/Microsoft.StorageSync/storageSyncServices/<sync service name>/syncGroups/<sync group name>/serverEndpoints/<endpoint name>"
        name                      = "<endpoint name>"
      ~ output                    = jsonencode({}) -> (known after apply)
      + response_export_values    = [
          + "*",
        ]
        tags                      = {}
        # (7 unchanged attributes hidden)
    }

Attempting to apply the plan results in the following error:

Error: creating/updating "Resource: (ResourceId \"/subscriptions/<subscription id>/resourceGroups/resource group name>/providers/Microsoft.StorageSync/storageSyncServices/<sync service name>/syncGroups/<sync group name>/serverEndpoints/<endpoint name>\" / Api Version \"2022-09-01\")": GET https://management.azure.com/subscriptions/<subscription id>/providers/Microsoft.StorageSync/locations/westus2/operations/eyJwYXJ0aXRpb25JZCI6Ijk1ZGNmNjg2LTA1NjktNDVmZS04OGQwLTcxOWUyNTg5NWJjNyIsIndvcmtmbG93SWQiOiI5Njk2NzE1Mi1jOWQxLTRhZDUtYWEwYy05NDExYjJjMjZjMmMiLCJ3b3JrZmxvd09wZXJhdGlvbklkIjoiNGYzNzdhNTctYWE5ZS00MDljLThiZGQtOWUwNzNkOTAxNThjIn0=
│ --------------------------------------------------------------------------------
│ RESPONSE 200: 200 OK
│ ERROR CODE: MgmtBadArgument
│ --------------------------------------------------------------------------------
│ {
│   "id": "/subscriptions/<subscription id>/providers/Microsoft.StorageSync/locations/westus2/operationresults/eyJwYXJ0aXRpb25JZCI6Ijk1ZGNmNjg2LTA1NjktNDVmZS04OGQwLTcxOWUyNTg5NWJjNyIsIndvcmtmbG93SWQiOiI5Njk2NzE1Mi1jOWQxLTRhZDUtYWEwYy05NDExYjJjMjZjMmMiLCJ3b3JrZmxvd09wZXJhdGlvbklkIjoiNGYzNzdhNTctYWE5ZS00MDljLThiZGQtOWUwNzNkOTAxNThjIn0=",
│   "name": "eyJwYXJ0aXRpb25JZCI6Ijk1ZGNmNjg2LTA1NjktNDVmZS04OGQwLTcxOWUyNTg5NWJjNyIsIndvcmtmbG93SWQiOiI5Njk2NzE1Mi1jOWQxLTRhZDUtYWEwYy05NDExYjJjMjZjMmMiLCJ3b3JrZmxvd09wZXJhdGlvbklkIjoiNGYzNzdhNTctYWE5ZS00MDljLThiZGQtOWUwNzNkOTAxNThjIn0=",
│   "status": "Failed",
│   "startTime": "2024-03-09T02:45:14.2762049Z",
│   "endTime": "2024-03-09T02:45:23.4411873Z",
│   "error": {
│     "code": "MgmtBadArgument",
│     "message": "Encountered an unexpected change in the value of property 'Tags'. old =  ; new : System.Collections.Generic.Dictionary`2[System.String,System.String]"
│   }
│ }
│ --------------------------------------------------------------------------------
│ 
│ 
│   with azapi_resource.server_endpoint["key"],
│   on files.tf line 112, in resource "azapi_resource" "server_endpoint":
│  112: resource "azapi_resource" "server_endpoint" {
@ms-henglu
Copy link
Collaborator

Hi @mrchops1024 ,

Thank you for taking time to report this issue!

I believe this is an upstream api issue. I have a workaround that might help with this case, would you please try to recreate this resource? You could use terraform taint command to mark the resource as tainted, then run apply command.

@mrchops1024
Copy link
Author

@ms-henglu - Thank you for the recommendation. This has resolved this particular issue (since we were fairly fresh in deployment). However, if we need to upgrade the resource again down the road, I can't say that replacing it will be the most optimal solution. Is there a way to keep track of the original issue so we can test when a fix is available?

@ms-henglu
Copy link
Collaborator

@mrchops1024 - Please create an issue in this repo: https://github.com/Azure/azure-rest-api-specs/tree/main/specification to track the upstream-api issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants