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.46k stars 4.54k forks source link

preferred_app_group_type Value None is not valid for new hostpools #26051

Open theTPH opened 1 month ago

theTPH commented 1 month ago

Is there an existing issue for this?

Community Note

Terraform Version

1.4.0

AzureRM Provider Version

3.104.2

Affected Resource(s)/Data Source(s)

azurerm_virtual_desktop_host_pool

Terraform Configuration Files

resource "azurerm_virtual_desktop_host_pool" "hp" {
  name                             = "vdpool-${var.workload}-${var.hp_name_description}-${var.environment}-${var.company}"
  resource_group_name              = var.rg_backend_name
  location                         = var.hp_location
  type                             = var.hp_type
  load_balancer_type               = var.lb_type
  friendly_name                    = var.hp_friendlyname
  description                      = var.hp_description
  validate_environment             = var.hp_validation_environment
  maximum_sessions_allowed         = var.hp_max_sessions_allowed
  personal_desktop_assignment_type = var.hp_personal_assignment
  custom_rdp_properties            = var.hp_rdp_properties
  start_vm_on_connect              = true
  tags                             = var.resource_tags
  public_network_access            = var.hp_public_network_access
  preferred_app_group_type         = var.hp_type == "Pooled" ? "None" : "Desktop"
}

Debug Output/Panic Output

Error: creating Host Pool (Subscription: "XXX" Resource Group Name: "XXX" Host Pool Name: "XXX"): unexpected status 400 (400 Bad Request) with error: 400: ActivityId: XXX 
Error: The PreferredAppGroupType value is incorrect. Please provide a valid type: Desktop or RailApplications.

Expected Behaviour

The Documentation states that:

Valid options are None, Desktop or RailApplications

This seems to be true for existing hostpools, as my existing multisession hostpools all got the property set to None by default. When creating a new hostpool I get the above error stating that the value is not valid. The Value is set to None in the tf plan.

Actual Behaviour

Apply Fails with Bad Request Error

Steps to Reproduce

Create new hostpool and set the preferred_app_group_type to "None".

Important Factoids

No response

References

No response

sinbai commented 1 month ago

Hi @theTPH thanks for opening this issue. However, I assume that this is an Azure API issue. I have submitted an API issue to track it. Could you please follow it for more updates?

marciobarbato commented 1 month ago

hello @sinbai I was checking a very similar issue happening with my pipelines, where property preferred_app_group_type is not reflecting current state of my state file, I explain:

My module defines preferred_app_group_type always as Desktop, I just checked the state and it has preferred_app_group_type = "Desktop", however on a recent run using provider 3.102.0 is wants to perform the same change ~ preferred_app_group_type = "None" -> "Desktop" # forces replacement

I wonder if it could be related to the bug you reported

sinbai commented 1 month ago

According to the Terraform doc, the description of the preferred_app_group_type attribute "Changing this forces a new resource to be created." and its default value is Desktop. Therefore, when the value in the status file is None and is specified as Desktop or not specified in the configuration, the above force replacement symptoms occur, which is correct behavior and has nothing to do with the API bug I reported.

marciobarbato commented 1 month ago

@sinbai Perhaps I was not clear on my previous text, but my current state file with already deployed resources has preferred_app_group_type = "Desktop", and still I see that change preferred_app_group_type = "None" -> "Desktop" # forces replacement