Terraform-provider-azurerm: AzureRM Appservice Plan fails to refresh after import

Created on 6 Jul 2018  ยท  6Comments  ยท  Source: terraform-providers/terraform-provider-azurerm

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 "+1" or "me too" comments, 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

Terraform Version

C:\Terraform\swk>terraform version
Terraform v0.11.7

  • provider.azurerm v1.8.0

Affected Resource(s)

  • azurerm_app_service_plan

Terraform Configuration Files

resource "azurerm_app_service_plan" "testapp" {
  name                = "testapp1234567"
  location            = "westeurope"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  kind                = "App"

  sku {
    tier = "Standard"
    size = "S1"
  }
}

Expected Behavior

after performing terraform Import the resource should not be changed

Actual Behavior

a new resource is created because multiple fields are empty

-/+ azurerm_app_service_plan.testapp (new resource required)
      id:                               "/subscriptions/603270d0-b196-42e0-a2f0-954087d4037c/resourceGroups/xxxxxx/providers/Microsoft.Web/serverFarms/testapp1234567" => <computed> (forces new resource)
      kind:                             "" => "App" (forces new resource)
      location:                         "" => "westeurope" (forces new resource)
      maximum_number_of_workers:        "" => <computed>
      name:                             "" => "testapp1234567" (forces new resource)
      properties.#:                     "" => <computed>
      resource_group_name:              "XXXXXX" => "XXXXXX"
      sku.#:                            "" => "1"
      sku.0.capacity:                   "" => <computed>
      sku.0.size:                       "" => "S1"
      sku.0.tier:                       "" => "Standard"
      tags.%:                           "0" => <computed>

Steps to Reproduce

  1. terraform import
  2. terraform apply
documentation question servicapp-service

All 6 comments

I'm seeing this same behavior but only with certain app service plans. Others import just fine.

Here is the debug output for an ASP that imports correctly:

2018-11-20T12:02:26.251-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: 2018/11/20 12:02:26 [DEBUG] Reading Azure App Service Plan &{<sub id> <rg> Microsoft.Web map[serverfarms:test-ASP]}
2018-11-20T12:02:26.251-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: 2018/11/20 12:02:26 [DEBUG] AzureRM Request:
2018-11-20T12:02:26.251-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: GET /subscriptions/<sub id>/resourceGroups/<rg>/providers/Microsoft.Web/serverfarms/test-ASP?api-version=2018-02-01 HTTP/1.1

And the debug output for an ASP that imports with most of its properties empty:

2018-11-20T11:40:10.356-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: 2018/11/20 11:40:10 [DEBUG] Reading Azure App Service Plan &{<sub id> <rg> Microsoft.Web map[serverFarms:test-ASP01]}
2018-11-20T11:40:10.356-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: 2018/11/20 11:40:10 [DEBUG] AzureRM Request:
2018-11-20T11:40:10.356-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.18.0_x4: GET /subscriptions/<sub id>/resourceGroups/<rg>/providers/Microsoft.Web/serverfarms/?api-version=2018-02-01 HTTP/1.1

It seems like the GET request on the unsuccessful one is querying all ASPs and not just the one that I'm importing. This behavior is the same with version 1.19 of the provider.

Oh fun, it looks like an issue with case sensitivity. For the unsuccessful import, I had copied the resource ID of the ASP from the Azure portal. For the successful import, I copied the resource ID from the Terraform azurerm_app_service_plan documentation. Notice serverFarms vs serverfarms. I was able to successfully import both by using serverfarms:

terraform import module.app_service_plan01.azurerm_app_service_plan.app_service_plan /subscriptions/<sub id>/resourceGroups/<rg>/providers/Microsoft.Web/serverfarms/test-ASP01

Works like a charm with serverfarms ( all lowercase ). You're a life savior @brianpcurran ๐Ÿ‘

hey @pfiene @jnancel

Glad to hear this has been resolved - as such I'm going to close this issue for the moment.

For other users running into this issue - Resource ID's are case-sensitive in Terraform - as such please ensure the casing on the serverfarms segment of the ID is in the correct casing, which will resolve this issue - for example from the App Service Plan Documentation:

$ terraform import azurerm_app_service_plan.instance1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/serverfarms/instance1

Thanks!

Creating App Service Plan with ASE is taking 40 minutes to finish. Some times returns 500 - internal server error.
Do we know if this known issue deploying app service plan with ASE?

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error ๐Ÿค– ๐Ÿ™‰ , please reach out to my human friends ๐Ÿ‘‰ [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings