This morning I have found the cause. The created "Container App" is used by the "Function App" which is deployed in/part of a "Container Apps Environment". Removing the function and "Container Apps Environment" makes it possible to delete the "Container App" too
Cannot remove resources due to invalid configuration (deployment stack missing)
I tried to remove a Resource Group but due to ignorance something went wrong causing a "invalid state". I had created a container app using Terraforms and I tried to remove that. Since it is a while ago I don't remember if it was trough a Terraform destroy action or that I did it using the portal but I removed everything in the resource group as intended. Except one resource everything was removed. The thing that still exists is a container app. I did try to remove in manually again but get an error, that I do have the right permissions but "however, the access is denied because of the deny assignment with name"
How do I force remove this resource?
I already found this article: https://learn.microsoft.com/en-us/answers/questions/1863369/orphan-resource-group-wont-delete
but it didn't help because there are no lock, there is no delployment stack and the resouce-group is also in a invalid state. If I run: "remove-azresource -ResourceId '/subscriptions/000000-0000-0000-0000-0000000000/resourceGroups/EBI-TerraFormTest_FunctionApps_0000000-0000-0000-0000-0000000000' -Force" I got Remove-AzResource: ResourceGroupNotFound : Resource group 'EBI-TerraFormTest_FunctionApps_0000000-0000-0000-0000-0000000000' could not be found.
2 answers
Sort by: Most helpful
-
-
LeelaRajeshSayana-MSFT 16,601 Reputation points
2024-11-07T21:18:31.6266667+00:00 Hi @Johannes Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.
Considering that the resource group is in invalid state, can you try running the following command using Azure CLI and see if it helps in removing the resource group
az group delete --name <YourResourceGroupName> --yes --no-wait
If the resource group fails to delete, run the following command against the resource group to list any deny assignments.
az role assignment list --scope "/subscriptions/000000-0000-0000-0000-0000000000/resourceGroups/YourResourceGroupName" --output json | jq '.[] | select(.roleDefinitionName=="DenyAssignment")'
If you find any deny assignments, you can run the following command to delete it
az role assignment delete --assignee <PrincipalId> --role "DenyAssignment" --scope "/subscriptions/<SubscriptionId>/resourceGroups/<YourResourceGroupName>"
Try deleting the resource group again with the first command after removing the deny assignments. If the command fails, try the following command to explicitly delete the Container App and then delete the resource group
az resource delete --ids /subscriptions/000000-0000-0000-0000-0000000000/resourceGroups/<YourResourceGroupName>/providers/Microsoft.App/containerApps/<ContainerAppName>
Please let us know if you still cannot delete the resource group after trying the above steps> Update
The created "Container App" is used by the "Function App" which is deployed in/part of a "Container Apps Environment". Removing the function and "Container Apps Environment" makes it possible to delete the "Container App"