5
votes

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?

2
that looks like a bug, that definition matches the example almost exactly. can you try removing kind = "Windows"? it shouldn't be needed4c74356b41
There is nothing wrong in the code, maybe you can try to delete unnecessary things and init, then apply again.Charles Xu
@CharlesXu What code are you referring to? Everything unnecessary is removed. I need the kind field too.Enrico
I mean the state file and the init directory. You do not need to delete the kind field, it's ok.Charles Xu
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

2 Answers

2
votes

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

0
votes

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!