{"record":{"id":"46a31cdf3da368df","repo":"microsoft/aspire","slug":"azure-operation-0-is-already-running-or-queued-for-the-same","errorCode":null,"errorMessage":"Azure operation '{0}' is already running or queued for the same resource scope. Wait for it to finish or run '{2}' before starting '{1}'.","messagePattern":"Azure operation '(.+?)' is already running or queued for the same resource scope\\. Wait for it to finish or run '(.+?)' before starting '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure/AzureProvisioningController.cs","lineNumber":2319,"sourceCode":"            return AzureOperationState.None;\n        }\n\n        return CreateActiveOperationState(model, intent);\n    }\n\n    private void RegisterQueuedOperation(AzureIntent intent, AzureOperationState queuedOperationState)\n    {\n        if (queuedOperationState.IsNone)\n        {\n            return;\n        }\n\n        lock (_operationStateLock)\n        {\n            if (_state.Status.ActiveOperation?.Operation is { } activeOperation &&\n                OperationsConflict(activeOperation, queuedOperationState))\n            {\n                throw new InvalidOperationException(FormatUserString(\n                    AzureProvisioningStrings.OperationAlreadyRunningOrQueued,\n                    activeOperation.DisplayName,\n                    intent.Operation.DisplayName,\n                    CancelCommandName));\n            }\n\n            foreach (var queuedOperation in _queuedOperationStates)\n            {\n                if (OperationsConflict(queuedOperation, queuedOperationState))\n                {\n                    throw new InvalidOperationException(FormatUserString(\n                        AzureProvisioningStrings.OperationAlreadyRunningOrQueued,\n                        queuedOperation.DisplayName,\n                        intent.Operation.DisplayName,\n                        CancelCommandName));\n                }\n            }\n","sourceCodeStart":2301,"sourceCodeEnd":2337,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure/AzureProvisioningController.cs#L2301-L2337","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before issuing an intent, check active operation\nvar status = controller.GetOperationStatus(resourceName);\nif (status?.ActiveOperation is { } active)\n{\n    // wait or cancel first\n    await controller.WaitForOperationAsync(active, cancellationToken);\n}","typeGuard":null,"tryCatchPattern":"try { await controller.QueueOperationAsync(intent); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"already running or queued\"))\n{\n    await Task.Delay(backoff, ct);\n    // retry once, or cancel the active operation first\n}","preventionTips":["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."],"tags":["azure","provisioning","concurrency","operation-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}