An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
Hello @Gulavani, Amruta
Thank you for reaching out to Microsoft Q&A.
I understand that you are unable to remove the Log Analytics workspace from the preprod subscription through the Terraform pipeline and would like to clean it up.
By default, when a Log Analytics workspace is deleted, Azure places it in a soft-delete state for 14 days so it can be recovered. If the requirement is to remove the workspace permanently and release the workspace name immediately, the workspace needs to be permanently deleted.
If you are using Terraform, please update the AzureRM provider features block as below so that Terraform permanently deletes the Log Analytics workspace during destroy:
provider "azurerm" {
features {
log_analytics_workspace {
permanently_delete_on_destroy = true
}
}
}
If the workspace is already in a soft-delete state, please recover the workspace first and then permanently delete it. You can also use Azure CLI to permanently delete the workspace:
az monitor log-analytics workspace delete --resource-group <resource-group-name> --workspace-name <workspace-name> --force
Before retrying the deletion, please also verify whether there are any related solutions, linked services, Azure Automation links, or resource locks associated with the workspace, as these may need to be removed depending on the exact error returned by the pipeline.
Reference:
Microsoft documentation: Delete and recover a Log Analytics workspace
Azure CLI reference: az monitor log-analytics workspace delete
Terraform provider reference: AzureRM provider features block
If you continue to experience the issue after following the above steps, please share the exact error message along with a screenshot so that we can investigate further.
If the answer is helpful, please click "upvote" it. If you have extra questions about this answer, please click "Comment".