-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_resource_group_template_deployment Destroy : Error 404 at the end of App Service Environments successfull deletion #10789
Comments
Hello, I opened an request to Azure support, about unexpected HTTP 404 error, on async operation url. I'm waiting for an answer. Error seems to be specific to App Service Environment. I found a workaround that seems to work, via a provisioner : resource "azurerm_resource_group_template_deployment" "ase" {
name = "${var.asename}-deployment-${local.timestamp}"
resource_group_name = data.azurerm_resource_group.rg.name
deployment_mode = "Incremental"
template_content = file("${path.module}/ase_template.json")
# these key-value pairs are passed into the ARM Template's `parameters` block
parameters_content = jsonencode({
"location" = {
value = var.location
}
"aseName" = {
value = var.asename
}
"kind" = {
value = var.kind
}
"ilbMode" = {
value = var.ilbMode
}
"subnetId" = {
value = data.azurerm_subnet.subnet_ase.id
}
"dnsSuffix" = {
value = local.dnsSuffix
}
"userWhitelistedIpRanges" = {
value = var.userWhitelistedIpRanges
}
})
timeouts {
create = "4h"
delete = "3h"
}
provisioner "local-exec" {
when = destroy
command = <<EOT
az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET -t $ARM_TENANT_ID > /dev/null
echo "az login result : $?"
az account set -s "${jsondecode(self.output_content).subscription_id.value}" > /dev/null
echo "az account set : $?"
az appservice ase delete --name "${jsondecode(self.parameters_content).aseName.value}" --resource-group "${self.resource_group_name}" --subscription "${jsondecode(self.output_content).subscription_id.value}" --yes
EOT
on_failure = continue
}
} A unexpected error is raised by provisioner at end of deletion :
I don't understand what exactly is going on under the hood. But |
👋 App Service Environments are natively supported in Terraform - so whilst it's possible to use an ARM Template deployment for this, you should be able to use the native resource instead, is there a specific piece of functionality you're using which isn't supported in the native resource? As you've mentioned above, unfortunately this is a bug in the App Service Environment API, whilst the native resource accounts for this quirk the template deployment resource doesn't - so I believe you'd be better of using the native resource here if possible? Thanks! |
Hi @tombuildsstuff, I already use native ressource But for old platform, not yet migrated to new ASE and created before may 2019, I still need to create ASE with custom DNS Prefix (see https://docs.microsoft.com/en-us/azure/app-service/environment/using-an-ase#dns-configuration). I need to be able to create App Service Environment with an old API : 2018-02-01. That's why I use an ARM template. |
Got it, just double checking 👍 |
For information, Azure Support answer : Issue : Azure REST API ASE Delete - Error 404 Async |
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_resource_group_template_deployment
Terraform Configuration Files
My ARM template : https://gist.github.com/jhauray/acd806c3802bc6096ba1ffaae29e76c2
You could almost use a template published by Azure : Create App Service Environment v2 with an ILB Address
Debug Output
https://gist.github.com/jhauray/bee86a3bb03e316bb26772537a89f021
Error message :
Error: removing items provisioned by this Template Deployment: waiting for deletion of Nested Resource "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Terr-testnb/providers/Microsoft.Web/hostingEnvironments/ase-zoned-legacy-ic-terraform": Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=404 -- Original Error: Code="ResourceNotFound" Message="The Resource 'Microsoft.Web/hostingEnvironments/ase-zoned-legacy-ic-terraform' under resource group 'Terr-testnb' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
Panic Output
Expected Behaviour
During Terraform Destroy, ARM template nested resources must be deleted properly, without error. Especcially if resource deletion is done successfully.
Actual Behaviour
GET /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/<resource-group-name>/providers/Microsoft.Web/hostingEnvironments/<ase-name>/operations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?api-version=2020-10-01 HTTP/1.1
REST API. The API send Response Code: 202Steps to Reproduce
terraform init
,terraform plan
andterraform apply
.terraform destroy
Important Factoids
References
Official doc about Operation tracking : https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations
The text was updated successfully, but these errors were encountered: