Description
We are encountering an issue with the Terraform AzureRM provider when transitioning an App Service / Function App Premium plan from elastic autoscaling to fixed manual scaling.
Initially, the service plan was configured with elastic autoscaling enabled:
premium_plan_auto_scale_enabled = true
maximum_elastic_worker_count = 4
Later, we disabled elastic autoscaling and switched to a fixed worker count managed by Terraform:
premium_plan_auto_scale_enabled = false
worker_count = 3
At the time of this change, the Terraform configuration still had:
maximum_elastic_worker_count = 4
The scaling to 3 instances was performed through Terraform, not manually via the Azure Portal.
Observed Behavior
When Terraform is run again, it fails with the following validation error:
maximum_elastic_worker_countcan only be specified with Elastic Premium SKUs or with Premium SKUs that havepremium_plan_auto_scale_enabledset totrue
Upon inspecting the Terraform state file, we observe that the state now contains:
maximum_elastic_worker_count = 3
even though:
-
premium_plan_auto_scale_enabledis set tofalse -
The Terraform configuration still specifies
maximum_elastic_worker_count = 4 -
The provider schema does not allow
maximum_elastic_worker_countwhen autoscaling is disabled
This results in persistent state drift and a plan failure before Terraform can proceed.