{"record":{"id":"36a4b9003aaa9b2e","repo":"OrchardCMS/OrchardCore","slug":"cannot-get-file-stream-of-the-file-path","errorCode":null,"errorMessage":"Cannot get file stream of the file '{path}'.","messagePattern":"Cannot get file stream of the file '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":648,"sourceCode":"    {\n        try\n        {\n            var blob = GetBlobReference(path);\n\n            if (!await blob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot get file stream because the file '{path}' does not exist.\");\n            }\n\n            return (await blob.DownloadAsync()).Value.Content;\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot get file stream of the file '{path}'.\", ex);\n        }\n    }\n\n    // Reduces the need to call blob.FetchAttributes, and blob.ExistsAsync,\n    // as Azure Storage Library will perform these actions on OpenReadAsync().\n    public Task<Stream> GetFileStreamAsync(IFileStoreEntry fileStoreEntry)\n    {\n        return GetFileStreamAsync(fileStoreEntry.Path);\n    }\n\n    public async Task<string> CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false)\n    {\n        try\n        {\n            var blob = GetBlobReference(path);\n\n            if (!overwrite && await blob.ExistsAsync())\n            {","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L630-L666","documentation":"GetFileStreamAsync wraps any non-FileStoreException failure during blob download (after the exists check) in a FileStoreException with this message. The inner exception holds the underlying Azure Storage RequestFailedException explaining the real cause.","triggerScenarios":"Calling IFileStore.GetFileStreamAsync(path) when the Azure SDK download throws — storage auth failure (403), container missing, network timeout, throttling (429/503), or the blob was deleted between the ExistsAsync check and the download.","commonSituations":"Expired or revoked storage account keys/SAS tokens; storage account unreachable from the server (firewall, DNS); race conditions where a concurrent request deletes the blob mid-download; transient Azure service errors.","solutions":["Inspect the InnerException (RequestFailedException) for the HTTP status: 403 = credentials, 404 = deleted between check and read, 429/503 = throttling, retry with backoff.","Verify storage credentials and connection string are valid and have read access to the container.","Retry the operation for transient failures (timeouts, 5xx) rather than treating them as permanent.","Check network connectivity/firewall rules between the app server and the storage account."],"exampleFix":"// before\nvar stream = await fileStore.GetFileStreamAsync(path); // may throw\n// after\ntry\n{\n    var stream = await fileStore.GetFileStreamAsync(path);\n}\ncatch (FileStoreException ex) when (ex.InnerException is RequestFailedException rfe && rfe.Status >= 500 || rfe?.Status == 429)\n{\n    // retry with backoff\n}","handlingStrategy":"retry","validationCode":"var file = await fileStore.GetFileInfoAsync(path);\nif (file == null) return null;","typeGuard":null,"tryCatchPattern":"try\n{\n    var stream = await fileStore.GetFileStreamAsync(path);\n}\ncatch (FileStoreException ex) when (ex.InnerException is RequestFailedException rfe && (rfe.Status >= 500 || rfe.Status == 429))\n{\n    // transient — retry with backoff\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Permanent failure reading {Path}\", path);\n    throw;\n}","preventionTips":["Classify inner RequestFailedException status before deciding to retry","Keep storage keys/SAS tokens valid and rotated safely","Ensure network/firewall access to the storage account","Handle blob-deleted races gracefully"],"tags":["azure-blob-storage","file-read","io"],"backgroundTag":"file-read-failed","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}