{"record":{"id":"c98765d73f4076b1","repo":"microsoft/aspire","slug":"no-cached-azure-resource-ids-were-found-for-resource-intent","errorCode":null,"errorMessage":"No cached Azure resource IDs were found for resource '{intent.ResourceName}'. Use '{ForgetStateCommandName}' to clear local state only.","messagePattern":"No cached Azure resource IDs were found for resource '(.+?)'\\. Use '(.+?)' to clear local state only\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure/AzureProvisioningController.cs","lineNumber":2118,"sourceCode":"                State = new(DeletingState, KnownResourceStateStyles.Info)\n            }).ConfigureAwait(false);\n        }\n\n        IReadOnlyList<string> resourceIds;\n        try\n        {\n            // A resource can have an in-progress deployment and already-created target resources.\n            // Cancel first to stop ARM from continuing to create/update resources while deletion is\n            // collecting and removing the known targets.\n            await CancelCachedDeploymentsAsync(\n                targetResources,\n                requireDeployment: false,\n                requiredDeploymentResourceName: null,\n                cancellationToken).ConfigureAwait(false);\n            resourceIds = await GetAzureResourceIdsForDeletionAsync(targetResources, cancellationToken).ConfigureAwait(false);\n            if (resourceIds.Count == 0)\n            {\n                throw new InvalidOperationException($\"No cached Azure resource IDs were found for resource '{intent.ResourceName}'. Use '{ForgetStateCommandName}' to clear local state only.\");\n            }\n\n            var effectiveLocation = await GetEffectiveResourceLocationAsync(GetDeploymentStateResourceName(targetResources[0]), cancellationToken).ConfigureAwait(false);\n            var currentContext = await GetCurrentAzureContextAsync(cancellationToken).ConfigureAwait(false);\n            await DeleteAzureResourceIdsAsync(resourceIds, intent.ResourceName, effectiveLocation, currentContext.Location, allowKeyVaultPurgeTimeout: true, cancellationToken).ConfigureAwait(false);\n            await ResetResourcesAsync(model, targetResources, preserveOverrides: true, cancellationToken).ConfigureAwait(false);\n        }\n        catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)\n        {\n            foreach (var resource in targetResources)\n            {\n                await PublishUpdateToResourceTreeAsync(resource, parentChildLookup, state => state with\n                {\n                    State = new(AzureProvisioningStrings.ResourceStateCanceled, KnownResourceStateStyles.Info)\n                }).ConfigureAwait(false);\n            }\n\n            throw;","sourceCodeStart":2100,"sourceCodeEnd":2136,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure/AzureProvisioningController.cs#L2100-L2136","documentation":"Thrown when a delete operation is requested but the local deployment state cache holds no Azure resource IDs for the named resource. Aspire deletes Azure resources from cached IDs recorded during earlier provisioning; with nothing cached there is nothing to delete, so the controller aborts and suggests using the forget-state command to clear local state without deleting cloud resources.","triggerScenarios":"Calling the delete/remove intent on a resource whose cached resource-ID list is empty, typically because the resource was never provisioned in this state store, the state was already forgotten/reset, or provisioning ran on a different machine/state directory.","commonSituations":"Running 'aspire delete' after a fresh clone where provisioning state was never created; provisioning deployed to a different subscription/location so IDs never got cached; previously running forget-state which wiped the cache; delete invoked for a resource name that was typo'd and has no cached entries.","solutions":["Run the ForgetState command (e.g. 'aspire delete --clear-state' / the forget-state command name) to clear local state only, since there are no cloud resources to delete.","Verify the resource name in the intent matches a resource that was actually provisioned from this state store.","Re-run provisioning to repopulate the cached resource IDs, then retry delete if cloud resources actually exist.","If the resources exist in Azure but are missing from cache, delete them manually in the Azure portal/CLI and forget local state."],"exampleFix":"// before\naspire delete --resource my-cosmos\n// throws: No cached Azure resource IDs...\n\n// after\naspire delete --resource my-cosmos --clear-state  // or the ForgetState command; clears local state only","handlingStrategy":"validation","validationCode":"// check cached state before issuing delete\nif (!provisioningState.HasCachedResourceIds(resourceName))\n{\n    // nothing to delete in Azure; use ForgetState to clear local state instead\n    provisioningState.ForgetState();\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { await controller.DeleteAsync(intent); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"No cached Azure resource IDs\"))\n{\n    logger.LogWarning(\"Nothing cached for {Resource}; clearing local state only\", intent.ResourceName);\n    await controller.ForgetStateAsync();\n}","preventionTips":["Never assume delete works after cloning a repo or switching state directories.","Run provisioning from the same machine/state store you will delete from.","Use ForgetState deliberately and document when local state was cleared.","Verify resource names against the provisioned model before issuing delete."],"tags":["azure","provisioning","state","delete"],"backgroundTag":"empty-result-set","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}