Issue running Terraform Apply and Destroy on Azure Cosmos Containers

Hello everyone,

I am running into issues running one of our infrastructure pipelines. This issue started last week. It seems that when we try to create or destroy Cosmos DB containers using Terraform Apply and Destroy the pipeline fails. We had no issues before and now we are. Does anyone know why this is happening? Did something change?

Thank you

Terraform Version
1.2.3

AzureRM Provider Version
2.97.0

Affected Resource(s)/Data Source(s)
Terraform Destroy and Terraform Appply

Terraform Configuration Files
running terraform destroy and terraform apply

Debug Output/Panic Output

Terraform Apply

│ Error: deleting Cosmos SQL Container “Tenants” (Account: “TenantAdmin”): documentdb.SQLResourcesClient#DeleteSQLContainer: Failure sending request: StatusCode=0 – Original Error: autorest/azure: Service returned an error. Status= Code=“ScopeLocked” Message=“The scope ‘/subscriptions//resourceGroups/cloud-perf-rg/providers/Microsoft.DocumentDB/databaseAccounts/cloud-perf-svl-db/sqlDatabases/Tenants/containers/TenantAdmin’ cannot perform delete operation because following scope(s) are locked: ‘/subscriptions//resourceGroups/cloud-perf-rg/providers/Microsoft.DocumentDB/databaseAccounts/cloud-perf-svl-db’. Please remove the lock and try again.”

Terraform Destroy


│ Error: deleting Cosmos SQL Container “Tenants” (Account: “TenantAdmin”): documentdb.SQLResourcesClient#DeleteSQLContainer: Failure sending request: StatusCode=0 – Original Error: autorest/azure: Service returned an error. Status= Code=“ScopeLocked” Message=“The scope ‘/subscriptions//resourceGroups/cloud-perf-rg/providers/Microsoft.DocumentDB/databaseAccounts/cloud-perf-svl-db/sqlDatabases/Tenants/containers/TenantAdmin’ cannot perform delete operation because following scope(s) are locked: ‘/subscriptions//resourceGroups/cloud-perf-rg/providers/Microsoft.DocumentDB/databaseAccounts/cloud-perf-svl-db’. Please remove the lock and try again.”

I found out what the issue. The flag to enable the lock resources was enabled in the configuration. The issue is resolved. Thank you.