Fix: Azure Cosmos DB Account Name Already Taken
Fix Azure Cosmos DB global name conflicts in Terraform. Handle unique naming, DNS resolution, and account restoration after soft deletion.
Troubleshooting
Fix Azure AKS service principal errors in Terraform. Covers expired credentials, managed identity migration, RBAC configuration, and SP recreation.
The service principal specified for AKS doesn't exist, has expired credentials, or has been deleted from Azure AD. Use a managed identity (recommended) instead of a service principal, or recreate the SP with valid credentials.
Error: creating AKS Cluster "prod-aks":
ServicePrincipalNotFound: Service principal 'xxx-xxx-xxx' not found
in Active Directory tenant 'yyy-yyy-yyy'.Error: updating AKS Cluster:
ServicePrincipalExpiredCredential: The service principal client secret
has expired.resource "azurerm_kubernetes_cluster" "main" {
name = "${var.project}-${var.environment}-aks"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
dns_prefix = "${var.project}-${var.environment}"
default_node_pool {
name = "system"
node_count = 2
vm_size = "Standard_D2s_v5"
}
# Use managed identity instead of service principal
identity {
type = "SystemAssigned"
}
}# Create new SP
az ad sp create-for-rbac --name "aks-${PROJECT}-${ENV}" \
--role Contributor \
--scopes "/subscriptions/${SUB_ID}/resourceGroups/${RG_NAME}" \
--years 3
# Use in Terraformresource "azurerm_kubernetes_cluster" "main" {
# ...
service_principal {
client_id = var.aks_sp_client_id
client_secret = var.aks_sp_client_secret
}
}# Reset credentials for existing SP
az ad sp credential reset --id $AKS_SP_CLIENT_ID --years 2
# Update Terraform variables with new secret# Update existing cluster to use managed identity
az aks update -g my-rg -n my-aks --enable-managed-identity
# Then update Terraform config to matchaz ad sp show --id $CLIENT_ID)az ad sp credential list --id $CLIENT_ID)AKS ServicePrincipalNotFound errors mean the SP is deleted or expired. The best fix is to migrate to managed identity — it eliminates credential management entirely. If you must use SPs, automate credential rotation and monitor expiry dates.
Fix Azure Cosmos DB global name conflicts in Terraform. Handle unique naming, DNS resolution, and account restoration after soft deletion.
Fix Azure Container Registry SKU errors in Terraform. Covers feature availability per tier, geo-replication, private endpoints, and in-place upgrades.
Fix Azure subnet in use errors when modifying VNets in Terraform. Covers resource dependencies, NSG dissociation, delegation conflicts, and force deletion.
Resolve Azure resource group not found errors in Terraform. Fix subscription context, naming issues, and dependency ordering for Azure deployments.