microsoft/aspire · error · InvalidOperationException
No cached Azure resource IDs were found for resource
Error message
No cached Azure resource IDs were found for resource '{intent.ResourceName}'. Use '{ForgetStateCommandName}' to clear local state only. What it means
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.
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.
Example fix
// before aspire delete --resource my-cosmos // throws: No cached Azure resource IDs... // after aspire delete --resource my-cosmos --clear-state // or the ForgetState command; clears local state only
Defensive patterns
Strategy: validation
Validate before calling
// check cached state before issuing delete
if (!provisioningState.HasCachedResourceIds(resourceName))
{
// nothing to delete in Azure; use ForgetState to clear local state instead
provisioningState.ForgetState();
return;
} Try / catch
try { await controller.DeleteAsync(intent); }
catch (InvalidOperationException ex) when (ex.Message.Contains("No cached Azure resource IDs"))
{
logger.LogWarning("Nothing cached for {Resource}; clearing local state only", intent.ResourceName);
await controller.ForgetStateAsync();
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No active cached Azure deployment was found for resource
- A of type cannot be assigned to a BicepValue< >.
- An azure location/region is required. Set the…
- An Azure principal parameter was not supplied a value…
- An Azure subscription id is required. Set the…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/c98765d73f4076b1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure/AzureProvisioningController.cs:2118
State = new(DeletingState, KnownResourceStateStyles.Info)
}).ConfigureAwait(false);
}
IReadOnlyList<string> resourceIds;
try
{
// A resource can have an in-progress deployment and already-created target resources.
// Cancel first to stop ARM from continuing to create/update resources while deletion is
// collecting and removing the known targets.
await CancelCachedDeploymentsAsync(
targetResources,
requireDeployment: false,
requiredDeploymentResourceName: null,
cancellationToken).ConfigureAwait(false);
resourceIds = await GetAzureResourceIdsForDeletionAsync(targetResources, cancellationToken).ConfigureAwait(false);
if (resourceIds.Count == 0)
{
throw new InvalidOperationException($"No cached Azure resource IDs were found for resource '{intent.ResourceName}'. Use '{ForgetStateCommandName}' to clear local state only.");
}
var effectiveLocation = await GetEffectiveResourceLocationAsync(GetDeploymentStateResourceName(targetResources[0]), cancellationToken).ConfigureAwait(false);
var currentContext = await GetCurrentAzureContextAsync(cancellationToken).ConfigureAwait(false);
await DeleteAzureResourceIdsAsync(resourceIds, intent.ResourceName, effectiveLocation, currentContext.Location, allowKeyVaultPurgeTimeout: true, cancellationToken).ConfigureAwait(false);
await ResetResourcesAsync(model, targetResources, preserveOverrides: true, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
foreach (var resource in targetResources)
{
await PublishUpdateToResourceTreeAsync(resource, parentChildLookup, state => state with
{
State = new(AzureProvisioningStrings.ResourceStateCanceled, KnownResourceStateStyles.Info)
}).ConfigureAwait(false);
}
throw;View on GitHub (pinned to 25830f84bd)