@@ -30,15 +30,18 @@ public class CloudBlobCoreFileStorageService : ICoreFileStorageService
3030 protected readonly IDiagnosticsSource _trace ;
3131 protected readonly ICloudBlobContainerInformationProvider _cloudBlobFolderInformationProvider ;
3232 protected readonly ConcurrentDictionary < string , ICloudBlobContainer > _containers = new ConcurrentDictionary < string , ICloudBlobContainer > ( ) ;
33+ protected readonly bool _initializeContainer ;
3334
3435 public CloudBlobCoreFileStorageService (
3536 ICloudBlobClient client ,
3637 IDiagnosticsService diagnosticsService ,
37- ICloudBlobContainerInformationProvider cloudBlobFolderInformationProvider )
38+ ICloudBlobContainerInformationProvider cloudBlobFolderInformationProvider ,
39+ bool initializeContainer = true )
3840 {
3941 _client = client ?? throw new ArgumentNullException ( nameof ( client ) ) ;
4042 _trace = diagnosticsService ? . SafeGetSource ( nameof ( CloudBlobCoreFileStorageService ) ) ?? throw new ArgumentNullException ( nameof ( diagnosticsService ) ) ;
4143 _cloudBlobFolderInformationProvider = cloudBlobFolderInformationProvider ?? throw new ArgumentNullException ( nameof ( cloudBlobFolderInformationProvider ) ) ;
44+ _initializeContainer = initializeContainer ;
4245 }
4346
4447 public async Task DeleteFileAsync ( string folderName , string fileName )
@@ -598,7 +601,11 @@ private string GetCacheControl(string folderName)
598601 private async Task < ICloudBlobContainer > PrepareContainer ( string folderName , bool isPublic )
599602 {
600603 var container = _client . GetContainerReference ( folderName ) ;
601- await container . CreateIfNotExistAsync ( isPublic ) ;
604+
605+ if ( _initializeContainer )
606+ {
607+ await container . CreateIfNotExistAsync ( isPublic ) ;
608+ }
602609
603610 return container ;
604611 }
0 commit comments