Skip to content

azurerm_batch_pool does not provide details on what caused "error: MissingRequiredProperty", but the details are available in the response. #27945

Open
@simonfelding

Description

Is there an existing issue for this?

  • I have searched the existing issues

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 comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.

Terraform Version

1.9.7

AzureRM Provider Version

4.9.0

Affected Resource(s)/Data Source(s)

azurerm_batch_pool

Terraform Configuration Files

resource "azurerm_batch_account" "main" {
  name                                = "${module.lz.shortname}batch"
  resource_group_name                 = module.lz.rg
  location                            = module.lz.location
  allowed_authentication_modes        = ["SharedKey", "AAD"]
  pool_allocation_mode                = "BatchService"
  storage_account_id                  = azurerm_storage_account.main.id
  storage_account_authentication_mode = "BatchAccountManagedIdentity"
  public_network_access_enabled       = false
  identity {
    type = "SystemAssigned"
  }
  network_profile {
    account_access {
      default_action = "Deny"
    }
    node_management_access {
      default_action = "Deny"
    }
  }
}

resource "azurerm_batch_pool" "main" {
  name                = "${module.lz.shortname}pool"
  resource_group_name = module.lz.rg
  account_name        = azurerm_batch_account.main.name
  display_name        = "main pool"
  vm_size             = var.batch_vm-size
  node_agent_sku_id   = var.batch_node-agent-sku-id
  target_node_communication_mode = "Simplified"
  network_configuration {
    public_address_provisioning_type = "NoPublicIPAddresses"
#    subnet_id = module.lz.subnet.id # not having the subnet causes the error in question, but there are many other potential causes.
  }
  auto_scale {
    evaluation_interval = "PT5M1S" # Every 5 minutes: The minimum value.
    formula = <<EOF
    startingNumberOfVMs = 0;
    maxNumberofVMs = ${var.batch_max-vm-count};
    pendingTasks = $PendingTasks.GetSample(180 * TimeInterval_Second);
    $TargetLowPriorityNodes = (max(pendingTasks) > 0) ? maxNumberofVMs : startingNumberOfVMs;
EOF
  }
  storage_image_reference {
    publisher = "microsoft-dsvm"
    offer     = "ubuntu-hpc"
    sku       = "2204"
    version   = "latest"
  }
  container_configuration {
    type = "DockerCompatible"
    container_registries { 
      registry_server = var.registry_url
      user_name       = var.registry_username
      password        = var.registry_password
    }
  }
  mount {
    azure_blob_file_system {
      account_name         = azurerm_storage_account.main.name
      container_name       = azurerm_storage_container.data.name
      relative_mount_path  = "input"
       sas_key = azurerm_storage_account.main.primary_access_key
    }
  }
  task_scheduling_policy {
    node_fill_type = "Spread"
  }
  start_task {
    command_line = "echo 'hello world'"
    wait_for_success   = true
    task_retry_maximum = 1
    user_identity {
      auto_user {
        scope = "Pool"
        elevation_level = "NonAdmin"
      }
    }
  }
}

Debug Output/Panic Output

Plan: 1 to add, 0 to change, 0 to destroy.
azurerm_batch_pool.main: Creating...
╷
│ Error: creating Pool (Subscription: "xxx"
│ Resource Group Name: "xxx"
│ Batch Account Name: "xxx"
│ Pool Name: "xxx"): unexpected status 400 (400 Bad Request) with error: MissingRequiredProperty: A required property was not specified in the request body.
│ RequestId:3c9eea51-f016-4fd9-bfab-c4574b6c4a14
│ Time:2024-11-07T16:42:40.0926329Z
│
│   with azurerm_batch_pool.main,
│   on batch.tf line 34, in resource "azurerm_batch_pool" "main":
│   34: resource "azurerm_batch_pool" "main" {
│

Expected Behaviour

It should provide the missing required property, which is actually included the json response but not displayed by terraform:

    "properties": {
        "statusCode": "BadRequest",
        "serviceRequestId": null,
        "statusMessage": "{\"error\":{\"code\":\"MissingRequiredProperty\",\"target\":\"BatchAccount\",\"message\":\"A required property was not specified in the request body.\\nRequestId:c977fae0-9fa0-41dc-9b12-d9e8b4c93913\\nTime:2024-11-07T16:44:29.8603896Z\",\"details\":[{\"code\":\"PropertyName\",\"message\":\"subnetId\"},{\"code\":\"Reason\",\"message\":\"Subnet must be specified for a pool with IPAddressProvisioningType as NoPublicIPAddresses.\"}]}}",

Actual Behaviour

From the properties.StatusMessage it displays the Error, but not the Reason with details on what required property that was missing, which is absolutely necessary to debug the configuration.

Ideally the provider actually knows about all the possible configuration complexities, but just returning the Reason and details would be really nice.

Steps to Reproduce

  1. terraform apply

Important Factoids

No response

References

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions