You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform Error deleting App Service Plan StatusCode=409 Server farm [asp] cannot be deleted because it has web app(s) [azure-function] assigned to it
#8241
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 (and AzureRM Provider) Version
Terraform v0.12.26
Azurerm 2.24.0
Affected Resource(s)
azurerm_app_service_plan
azurerm_function_app
Terraform Configuration Files
# Copy-paste your Terraform configurations here - for large Terraform configs,# please use a service like Dropbox and share a link to the ZIP file. For# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
Provider:# Configure the Microsoft Azureprovider"azurerm" {
version ="~> 2.24.0"
use_msi =truefeatures {}
client_id =var.client_id
client_secret =var.client_secret
tenant_id =var.tenant_id
subscription_id =var.subscription_id
}
provider"azuread" {
version ="~> 0.3"
subscription_id =var.subscription_id
client_id =var.client_id
client_secret =var.client_secret
tenant_id =var.tenant_id
}
Apply build should have completed ok
It does work fine if I manually delete the function and its service plan using the Azure Portal
Actual Behavior
It fails, here is a summary of the relevant part of the DEBUG log:
2020-08-25T06:31:23.256Z [DEBUG] plugin.terraform-provider-azurerm_v2.24.0_x5: {"Code":"Conflict","Message":"Server farm 'asp-staging' cannot be deleted because it has web app(s) function-staging assigned to it.","Target":null,"Details":[{"Message":"Server farm 'asp-staging' cannot be deleted because it has web app(s) function-staging assigned to it."},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"11003","MessageTemplate":"Server farm '{0}' cannot be deleted because it has web app(s) {1} assigned to it.","Parameters":["asp-staging","function-staging"],"Code":"Conflict","Message":"Server farm 'asp-staging' cannot be deleted because it has web app(s) function-staging assigned to it."}}],"Innererror":null}
...
Error: Error deleting App Service Plan "asp-staging" (Resource Group "my-resource-group"): web.AppServicePlansClient#Delete: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>
Steps to Reproduce
Create the following resources
resource "azurerm_app_service_plan" "asp" {
name = "asp-${var.environment}"
resource_group_name = var.rg_name
location = var.location
kind = "FunctionApp"
reserved = true
sku {
tier = "ElasticPremium"
size = "EP1"
}
}
resource "azurerm_function_app" "function" {
name = "function-${var.environment}"
resource_group_name= var.rg_name
location= var.location
app_service_plan_id= azurerm_app_service_plan.asp.id
storage_connection_string=azurerm_storage_account.storage.primary_connection_string
os_type = "linux"
site_config {
linux_fx_version = "DOCKER|${data.azurerm_container_registry.acr.login_server}/${var.image_name}:latest"
}
identity {
type = "SystemAssigned"
}
depends_on = [azurerm_app_service_plan.asp]
app_settings = {
#Lots of variables, but irrelevant for this issue I assume?
}
version = "~2"
}
This forum is intended to be used for feature enhancements and bugs in the Azure Provider - so that we can keep this forum focused on that we instead ask that broader questions are raised using one of the Community Resources. As such I'm going to close this issue for the moment, but I believe you should be able to get an answer for this using one of the Community Resources.
@stianbearingpoint there's a missing dependency between these two resources which is why this is happening, unfortunately we're unable to assist with every configuration issue which is why we ask users open these on the forum (or another community location) instead - however adding a dependency between the two should resolve this :)
I still get the same error, I even tried with a null_resource with a sleep of 30 sec between them. Have I missunderstood what you meant by adding dependency?
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 👉 hashibot-feedback@hashicorp.com. Thanks!
ghost
locked and limited conversation to collaborators
Sep 24, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.12.26
Azurerm 2.24.0
Affected Resource(s)
azurerm_app_service_plan
azurerm_function_app
Terraform Configuration Files
Debug Output
https://gist.github.com/stianbearingpoint/19b4daff45b28d45a7ba9946a0c5f46f
Panic Output
Expected Behavior
Apply build should have completed ok
It does work fine if I manually delete the function and its service plan using the Azure Portal
Actual Behavior
It fails, here is a summary of the relevant part of the DEBUG log:
Steps to Reproduce
Important Factoids
References
I have an open Stackoverflow post, it was there they suggested to open bug report here:
https://stackoverflow.com/questions/63573535/terraform-error-deleting-app-service-plan-statuscode-409-server-farm-asp-canno?noredirect=1#comment112418835_63573535
The text was updated successfully, but these errors were encountered: