AZURE

ResourceGroupNotFound - Resource Group Not Found: Name Invalid or Deleted

ARM can't locate the resource group—the name format might be invalid (1-90 characters, alphanumeric plus underscore/parentheses/hyphen/period), the group was deleted, or you're hitting the wrong subscription. This 404 client-side error occurs after ARM validates the name format but can't find the group. Resource group names are case-insensitive in Azure CLI but case-sensitive in direct ARM API calls, so case mismatches can cause failures. Soft-deleted resource groups exist during retention but aren't accessible via standard GET operations. Applies to VM resource groups, AKS clusters, Azure SQL databases, and App Service deployments.

#Common Causes

  • Invalid Resource Group Name Format: The name contains invalid characters or exceeds the 90 character limit. Allowed characters are: alphanumeric, underscore, parentheses, hyphen, and period. ARM rejects names that violate these rules before querying.
  • Soft-Deleted Resource Group: Resource groups exist in a "Deleted" provisioningState with the retention period still active. During retention, standard GET operations return ResourceGroupNotFound even though the resource group technically exists. Retention period is configurable but varies.
  • Wrong Subscription Context: Resource groups in different subscriptions aren't accessible from your current subscription context. ARM only queries resource groups within your current subscription context. The resource group is in subscription A but you're authenticated to subscription B.
  • Case Sensitivity Mismatch: Resource group names are case-insensitive in Azure CLI but case-sensitive in ARM API calls. Using the exact name from CLI in an ARM API call with a case mismatch causes ResourceGroupNotFound.

Solutions

  1. 1Step 1: Diagnose - Check if resource group exists: az group exists --name <rg-name> --output table
  2. 2Step 2: Diagnose - Verify current subscription context: az account show --query "{subscriptionId:id, name:name}" --output table
  3. 3Step 3: Diagnose - List all resource groups in current subscription: az group list --query "[].{name:name, location:location}" --output table
  4. 4Step 4: Diagnose - Verify resource group name format (1-90 characters, alphanumeric + underscore/parentheses/hyphen/period).
  5. 5Step 5: Fix - Create missing resource group: az group create --name <rg-name> --location <location>
  6. 6Step 6: Fix - Switch to correct subscription if needed: az account set --subscription <sub-id>
  7. 7Step 7: Fix - Ensure case matches exactly when using ARM API directly.
  8. 8Step 8: Verify - Retry resource group lookup: az group show --name <rg-name> --output table

</>Code Examples

Resource Group Lookup and Creation
1# This script helps diagnose ResourceGroupNotFound errors
2
3# Step 1: Get current subscription context
4echo "Checking current subscription..."
5az account show --query "{subscriptionId:id, name:name}" --output table
6
7# Step 2: Example resource group name (replace with your actual resource group name)
8RG_NAME="my-resource-group"
9echo "Checking resource group: $RG_NAME"
10
11# Step 3: Check if resource group exists
12echo "Checking if resource group exists..."
13if az group exists --name $RG_NAME --output tsv | grep -q "true"; then
14  echo "Resource group exists"
15else
16  echo "Resource group does not exist"
17fi
18
19# Step 4: List all resource groups in current subscription
20echo "Listing all resource groups in current subscription..."
21az group list --query "[].{name:name, location:location}" --output table
22
23# Step 5: Verify resource group name format (1-90 characters, alphanumeric + underscore/parentheses/hyphen/period)
24if [[ ! $RG_NAME =~ ^[a-zA-Z0-9._()-]{1,90}$ ]]; then
25  echo "ERROR: Invalid resource group name format"
26  echo "Allowed: 1-90 characters, alphanumeric + underscore/parentheses/hyphen/period"
27  exit 1
28fi
29echo "Resource group name format is valid"
30
31# Step 6: Try to show resource group details
32echo "Attempting to show resource group details..."
33if az group show --name $RG_NAME --output table 2>&1; then
34  echo "Resource group found and accessible"
35else
36  echo "Resource group not found or not accessible"
37  
38  # Step 7: Create resource group if it doesn't exist
39  LOCATION="eastus"
40  echo "Creating resource group $RG_NAME in location $LOCATION..."
41  az group create --name $RG_NAME --location $LOCATION --output table
42fi
43
44# Step 8: List all subscriptions to find where resource group might be
45echo "Listing all accessible subscriptions..."
46az account list --query "[].{subscriptionId:id, name:name, state:state}" --output table
47
48# Step 9: Check resource group in different subscription (if needed)
49# SUBSCRIPTION_ID="00000000-0000-0000-0000-000000000000"
50# az account set --subscription $SUBSCRIPTION_ID
51# az group show --name $RG_NAME --output table

Related Errors

Provider Information

This error code is specific to AZURE services. For more information, refer to the official AZURE documentation.

ResourceGroupNotFound - Resource Group Not Found: Name Invalid or Deleted | AZURE Error Reference | Error Code Reference