From eb1284dbd0004017947f9b8c66003789c71bdde5 Mon Sep 17 00:00:00 2001 From: Stephen Lee Date: Mon, 28 Sep 2026 14:53:43 -0400 Subject: [PATCH] ROCK-9041: Dispose ContentStream in AzureBlobStorage.SaveContent Wrap the blob upload in a using block so the provider disposes BinaryFile.ContentStream after saving, matching the Database and FileSystem providers. Callers that assign a FileStream and then delete the temp file (SignatureDocumentTemplateService.UpdateDocumentStatus) were hitting IOException because the handle was still open, which broke the Process Signature Documents job. Co-Authored-By: Claude Fable 5.1 --- Rock/Storage/Provider/AzureBlobStorage.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Rock/Storage/Provider/AzureBlobStorage.cs b/Rock/Storage/Provider/AzureBlobStorage.cs index c1342556656..7404651950f 100644 --- a/Rock/Storage/Provider/AzureBlobStorage.cs +++ b/Rock/Storage/Provider/AzureBlobStorage.cs @@ -108,9 +108,23 @@ The exception was being thrown by the second call to BlobClient.Upload() when re Reason: Wide SMS image attachments stored in Azure cause exceptions in Communication Wizard. https://github.com/SparkDevNetwork/Rock/issues/5719 */ - blobClient.Upload( binaryFile.ContentStream, overwrite: true ); + /* + 9/28/2026 - SL (SECC) - fileSize = binaryFile.ContentStream.Length; + Dispose the content stream after uploading so this provider follows the same + contract as the Database and FileSystem providers. Callers such as + SignatureDocumentTemplateService.UpdateDocumentStatus assign a FileStream to + ContentStream, save, then File.Delete() the temp file; leaving the stream open + leaked the file handle and caused the delete to throw IOException. + + Reason: ROCK-9041 Process Signature Documents job fails with file lock on Azure provider. + */ + using ( var stream = binaryFile.ContentStream ) + { + blobClient.Upload( stream, overwrite: true ); + + fileSize = stream.Length; + } } ///