{"record":{"id":"824e2b1bab477a5f","repo":"OrchardCMS/OrchardCore","slug":"error-while-copying-file-srcpath-copy-operation-failed-with","errorCode":null,"errorMessage":"Error while copying file '{srcPath}'; copy operation failed with status {properties.Value.CopyStatus} and description {properties.Value.CopyStatusDescription}.","messagePattern":"Error while copying file '(.+?)'; copy operation failed with status (.+?) and description (.+?)\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":616,"sourceCode":"                throw new FileStoreException($\"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.\");\n            }\n\n            await newBlob.StartCopyFromUriAsync(oldBlob.Uri);\n\n            await Task.Delay(250);\n            var properties = await newBlob.GetPropertiesAsync();\n\n            while (properties.Value.CopyStatus == CopyStatus.Pending)\n            {\n                await Task.Delay(250);\n\n                // Need to fetch properties or CopyStatus will never update.\n                properties = await newBlob.GetPropertiesAsync();\n            }\n\n            if (properties.Value.CopyStatus != CopyStatus.Success)\n            {\n                throw new FileStoreException($\"Error while copying file '{srcPath}'; copy operation failed with status {properties.Value.CopyStatus} and description {properties.Value.CopyStatusDescription}.\");\n            }\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot copy file '{srcPath}' to '{dstPath}'.\", ex);\n        }\n    }\n\n    public async Task<Stream> GetFileStreamAsync(string path)\n    {\n        try\n        {\n            var blob = GetBlobReference(path);\n","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L598-L634","documentation":"After starting an asynchronous server-side copy (StartCopyFromUriAsync), CopyFileAsync polls the destination blob's properties and throws FileStoreException if CopyStatus is not Success (e.g. Failed or Aborted), including Azure's CopyStatusDescription. The copy is a server-side storage operation, so failure details come from the storage service.","triggerScenarios":"StartCopyFromUriAsync completed but the resulting copy failed: source blob modified or permissions revoked mid-copy (SAS expired), size limits exceeded, or the copy was aborted; detected when properties report a non-Success CopyStatus after the polling delay.","commonSituations":"Copies from another storage account using short-lived SAS tokens that expire before the copy finishes; very large blobs copied across accounts; storage account failovers; throttling during copy.","solutions":["Inspect CopyStatusDescription in the message for Azure's failure reason.","If copying across accounts, ensure the source SAS is valid long enough or use a stored access policy.","Retry the copy operation; transient failures often succeed on retry.","For large or critical copies, poll CopyStatus in a loop instead of relying on the fixed 250 ms delay."],"exampleFix":"// before\nawait _fileStore.CopyFileAsync(srcPath, dstPath);\n// after\ntry\n{\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex)\n{\n    _logger.LogError(ex, \"Blob copy failed for {Src} -> {Dst}; will retry\", srcPath, dstPath);\n    await _fileStore.TryDeleteFileAsync(dstPath);\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex) when (ex.Message.Contains(\"copy operation failed\"))\n{\n    _logger.LogWarning(ex, \"Async blob copy failed for {Src}; retrying\", srcPath);\n    await _fileStore.TryDeleteFileAsync(dstPath);\n    await Task.Delay(TimeSpan.FromSeconds(2));\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}","preventionTips":["Use long-lived or stored-access-policy SAS when copying across accounts.","Allow extra time for large blobs; server-side copies are asynchronous.","Retry copies; most status failures are transient or permission-related.","Read CopyStatusDescription in the message for Azure's root cause."],"tags":["azure-blob","file-storage","copy-failed"],"backgroundTag":"file-write-failed","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}