microsoft/aspire · error · InvalidOperationException
Azure operation ' ' is already running or queued for the…
Error message
Azure operation '{0}' is already running or queued for the same resource scope. Wait for it to finish or run '{2}' before starting '{1}'. What it means
Thrown while queueing an Azure provisioning operation when an operation is currently ACTIVE for the same resource scope and conflicts with the new intent. The controller serializes conflicting operations under _operationStateLock; starting a second conflicting operation would corrupt state, so it throws and directs the user to wait or cancel the running operation.
Solutions
- Wait for the active operation to finish, then retry the new operation.
- Run the Cancel command (CancelCommandName) to cancel the active operation before starting the new one.
- Inspect _state.Status.ActiveOperation / the dashboard to confirm which operation is running and whether it is stuck.
- Serialize operations in your automation: poll operation status and only issue the next intent after completion.
Defensive patterns
Strategy: retry
Validate before calling
// before issuing an intent, check active operation
var status = controller.GetOperationStatus(resourceName);
if (status?.ActiveOperation is { } active)
{
// wait or cancel first
await controller.WaitForOperationAsync(active, cancellationToken);
} Try / catch
try { await controller.QueueOperationAsync(intent); }
catch (InvalidOperationException ex) when (ex.Message.Contains("already running or queued"))
{
await Task.Delay(backoff, ct);
// retry once, or cancel the active operation first
} Prevention
- Serialize provisioning intents per resource in automation/CI.
- Poll operation status instead of fire-and-forget duplicates.
- Cancel a stuck operation explicitly before starting a conflicting one.
- Debounce duplicate dashboard/CLI action triggers.
When it happens
Trigger: Invoking a new provisioning/deploy/delete intent while OperationsConflict(activeOperation, queuedOperationState) is true for an operation that is already running (not merely queued) on the same resource scope.
Common situations: Double-invoking deploy/delete from CLI or MCP while a long Bicep deployment is in flight; clicking a resource action twice in the dashboard; automation scripts issuing overlapping operations without waiting for the first to complete.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- 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…
- Azure provisioning failure with published failure details.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/46a31cdf3da368df.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure/AzureProvisioningController.cs:2319
return AzureOperationState.None;
}
return CreateActiveOperationState(model, intent);
}
private void RegisterQueuedOperation(AzureIntent intent, AzureOperationState queuedOperationState)
{
if (queuedOperationState.IsNone)
{
return;
}
lock (_operationStateLock)
{
if (_state.Status.ActiveOperation?.Operation is { } activeOperation &&
OperationsConflict(activeOperation, queuedOperationState))
{
throw new InvalidOperationException(FormatUserString(
AzureProvisioningStrings.OperationAlreadyRunningOrQueued,
activeOperation.DisplayName,
intent.Operation.DisplayName,
CancelCommandName));
}
foreach (var queuedOperation in _queuedOperationStates)
{
if (OperationsConflict(queuedOperation, queuedOperationState))
{
throw new InvalidOperationException(FormatUserString(
AzureProvisioningStrings.OperationAlreadyRunningOrQueued,
queuedOperation.DisplayName,
intent.Operation.DisplayName,
CancelCommandName));
}
}
View on GitHub (pinned to 25830f84bd)