5

Ever since last night I get an error when deploying my web app to azure using Terraform:

Error creating/updating App Service Plan "test-euw-asp" (Resource Group "test-middle-euw-rg"): web.AppServicePlansClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="LinkedInvalidPropertyId" Message="Property id '' at path 'properties.hostingEnvironmentProfile.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."

Looks like it is sending an empty "id" in the "hostingEnvironmentProfile" object.

2020-02-25T15:31:56.0433755Z 2020-02-25T15:31:56.041Z [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4.exe: {"kind":"Windows","location":"westeurope","properties":{"hostingEnvironmentProfile":{"id":""},"perSiteScaling":false,"maximumElasticWorkerCount":1,"reserved":false,"isXenon":false},"sku":{"name":"S1","tier":"standard","size":"S1","capacity":1},"tags":{}}

I did set the provider version to 1.44.0

provider "azurerm" {
  version = "~>1.44.0"
}

My terraform configuration

resource "azurerm_resource_group" "rg" {
    name = var.ResourceGroupNameApp
    location = "West europe"
}

resource "azurerm_app_service_plan" "asp" {
    name = var.asp-name
    resource_group_name = azurerm_resource_group.rg.name
    location = azurerm_resource_group.rg.location
    kind = "Windows"

    sku {
        size = var.asp-sku-size
        tier = var.asp-sku-tier
    }
}

I'm not using the hosting environment anywhere. Anyone having the same issue? I did submit a support ticket on the Terraform github: https://github.com/terraform-providers/terraform-provider-azurerm/issues/5884

But does anyone know a work-around?

Enrico
  • 2,734
  • 1
  • 27
  • 40
  • that looks like a bug, that definition matches the example almost exactly. can you try removing `kind = "Windows"`? it shouldn't be needed – 4c74356b41 Feb 26 '20 at 09:50
  • There is nothing wrong in the code, maybe you can try to delete unnecessary things and init, then apply again. – Charles Xu Feb 27 '20 at 03:30
  • @CharlesXu What code are you referring to? Everything unnecessary is removed. I need the kind field too. – Enrico Feb 27 '20 at 08:48
  • I mean the state file and the init directory. You do not need to delete the kind field, it's ok. – Charles Xu Feb 27 '20 at 08:57
  • 2
    We have the exact same error in all our terraform scripts that where working with 1.44 before without problems. We also tried different values for kind with no succes. – Denis Thomas Feb 28 '20 at 07:45
  • I'm getting the same error too , it was working fine last week , and now nothing works – ZIADIA Oussama Feb 28 '20 at 09:23
  • Yup, got the exact same situation. Nothing works anymore. I opened a pull request but i'm not sure if it will be fixed for older versions as well. And also don't know how long it is going to take ;____; – Enrico Feb 28 '20 at 09:46
  • After attempting this and rolling our terraform code back to the previously working 1.44 version, my terraform apply is still not working! – Rikki Feb 28 '20 at 15:22

2 Answers2

2

So basically this problem is caused by a bug in the provider. A workaround could be to delete everything and re-create it. (as suggested by Rikki) But nothing assures you that you won't run into the same issue again in the future... Also deleting resources is not ideal, certainly not in a production environment...

What I did: I disabled the "terraform apply" step in my release pipeline (because the resources were already created). So we only needed to deploy our app service and update our database.

This issue will only be fixed in the next release. So i'd suggest upgrading to the new version. https://github.com/terraform-providers/terraform-provider-azurerm/pull/5915#issuecomment-594357740

Enrico
  • 2,734
  • 1
  • 27
  • 40
0

My temporary solution to get us unblocked was to manually delete the affected resources, then re-run the terraform at 1.44. Luckily this was just affecting our development environment.

This is less than ideal, but if you're totally stuck, and it's safe to temporarily delete your app service, then recreate it, this might help you!

Rikki
  • 1,142
  • 15
  • 17
  • I have a hypothesis that creating new resources from scratch with azurerm 2.0 might work, but there obviously is a bug in upgrading existing resources. – Rikki Feb 28 '20 at 18:19
  • When creating new resources won't we run into the same problem when trying to update them? – Enrico Mar 02 '20 at 08:37
  • I've not tested it I'm afraid. My thinking is that updating within azurerm 2.0 created resources will work, but that something about how they were created in azurerm 1.44 makes them incompatible with how azurerm 2.0 creates/updates them. Which is less than ideal! – Rikki Mar 02 '20 at 23:22
  • 1
    I tested that, and even updating resources created with azurerm 2.0 will produce the same error. – Denis Thomas Mar 03 '20 at 15:48
  • According to the people who maintain the Terraform / azure plugin git repo this bug only occurs in 2.0. So i'd say remove everything and change your version to 1.44 and then try to recreate it. – Enrico Mar 04 '20 at 13:06
  • Edit: I tried -> it does not work. You'll get the exact same error – Enrico Mar 17 '20 at 15:46