Terraform-provider-azurerm: azurerm_app_service_plan maximum_number_of_workers "NumberOfWorkers is invalid" or "invalid or unknown key"

Created on 2 Aug 2018  路  10Comments  路  Source: terraform-providers/terraform-provider-azurerm

Terraform Version

terraform -v
Terraform v0.11.7

  • provider.azurerm v1.11.0
  • provider.random v1.3.1

Affected Resource(s)


ls

  • azurerm_app_service_plan

Terraform Configuration Files

$ cat app_service_plan.tf 
resource "azurerm_app_service_plan" "ilbase-plan" {
  name                = "ilbase-app-service-plan"
  location            = "${azurerm_resource_group.appservice-rg.location}"
  resource_group_name = "${azurerm_resource_group.appservice-rg.name}"

  sku {
    tier = "Isolated"
    size = "I1"
  }
 properties {
 app_service_environment_id = "/subscriptions/xxxxxxxxxxxxxxxxxx/resourceGroups/currencyase/providers/Microsoft.Web/hostingEnvironments/CurrencyASE"
 maximum_number_of_workers = "1"
 }
}

Debug Output

I created a gist with both the output when specifying maximum_number_of_workers and an example when it is not specified.

https://gist.github.com/davidlbyrne/db3b08d40b6e8de14270a65748e4e24e

Panic Output

Expected Behavior

The app service plan should be regardless because maximum_number_of_workers is an optional parameter.

Actual Behavior

  • azurerm_app_service_plan.ilbase-plan: web.AppServicePlansClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="NumberOfWorkers is invalid." Details=[{"Message":"NumberOfWorkers is invalid."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"51012","Message":"NumberOfWorkers is invalid.","MessageTemplate":"{0} is invalid.","Parameters":["NumberOfWorkers"]}}]

Or

Error: azurerm_app_service_plan.ilbase-plan: properties.0: invalid or unknown key: maximum_number_of_workers

Steps to Reproduce

  1. terraform apply

Important Factoids

deploy an app_service_plan with an existing ASE ID

References

bug servicapp-service

Most helpful comment

Stumbled into this just now as well. Current workaround is to use "capacity" part of "sku".

  sku {
      tier = "Isolated"
      size = "I1"
      capacity = 1  # <--------------------
  }

@CryptonZylog Isn't that a bit sketch to run an terraform apply on?
When I use PowerShell Get-AzureRMAppServicePlan, under sku is shows capacity of 0. If I set it to 1 it would overwrite that?

All 10 comments

Looking at the source resource_arm_app_service_plan.go I see that maximum_number_of_workers is not inside the scope of the properties object. Either the documentation needs to be updated or this needs to be fixed in the source.

                        "properties": {
                                Type:     schema.TypeList,
                                Optional: true,
                                Computed: true,
                                MaxItems: 1,
                                Elem: &schema.Resource{
                                        Schema: map[string]*schema.Schema{
                                                "app_service_environment_id": {
                                                        Type:     schema.TypeString,
                                                        Optional: true,
                                                        ForceNew: true,
                                                },
                                                "reserved": {
                                                        Type:     schema.TypeBool,
                                                        Optional: true,
                                                        Default:  false,
                                                },
                                                "per_site_scaling": {
                                                        Type:     schema.TypeBool,
                                                        Optional: true,
                                                        Default:  false,
                                                },
                                        },
                                },
                        },

                        "maximum_number_of_workers": {
                                Type:     schema.TypeInt,
                                Computed: true,
                        },

I have a fix and would like to push the branch and create a pull request. Can get the correct permissions to push my branch?

@davidlbyrne the field maximum_number_of_workers is currently Computed which means it's read-only based on the value returned from the API. It's possible that this field may need to be set when used in combination with an App Service Environment - do you have a reference for this field needing to be set?

I have a fix and would like to push the branch and create a pull request. Can get the correct permissions to push my branch?

Thanks for this contribution - you can send a pull request by creating and pushing to a fork which will then allow you to open a PR, there's information available here: https://help.github.com/articles/fork-a-repo/

Thanks!

@tombuildsstuff I think I was confused about the root cause of the error. I was simply moving the parameter into the properties scope. I don't believe this resolves the issue. In the response from the Microsoft API you can see that sending "0" is not a valid number of workers for the ASE. Is it possible to change this parameter to a value that can be set by the user? How will this effect the current implementation. Will it break anything?

@davidlbyrne sure we can make it possible for this field to be set, but this is only applicable to App Service Environments (which Terraform doesn't currently support) - as such we'll need to test this manually rather than with an acceptance test (since the ASE API's are broken)

Stumbled into this just now as well. Current workaround is to use "capacity" part of "sku".

  sku {
      tier = "Isolated"
      size = "I1"
      capacity = 1  # <--------------------
  }

I've ran into this problem as well.

Looks like we can't use the "resource" just the "data" source since i can't successfully run a terraform apply with this in the state file.

Error creating/updating App Service Plan
"NumberOfWorkers is invalid."
"ExtendedCode":"51012","Message":"NumberOfWorkers is invalid."

Stumbled into this just now as well. Current workaround is to use "capacity" part of "sku".

  sku {
      tier = "Isolated"
      size = "I1"
      capacity = 1  # <--------------------
  }

@CryptonZylog Isn't that a bit sketch to run an terraform apply on?
When I use PowerShell Get-AzureRMAppServicePlan, under sku is shows capacity of 0. If I set it to 1 it would overwrite that?

Thanks for the help @Midacts this is working now.

Thanks for the reply. I'll give it a shot.

Was this page helpful?
0 / 5 - 0 ratings