From 14520daa121411d1feea422e600302c62c8124f6 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Mon, 30 Mar 2026 14:15:21 +0200 Subject: [PATCH 1/2] Add AzureBlobStorage factory method accepting BlobServiceClient Allows creating IAzureBlobStorage directly from a BlobServiceClient instance, matching the documented API in the wiki and removing the need for reflection workarounds. --- FluentStorage.Azure.Blobs/Factory.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/FluentStorage.Azure.Blobs/Factory.cs b/FluentStorage.Azure.Blobs/Factory.cs index 5e04d16..126bb6f 100644 --- a/FluentStorage.Azure.Blobs/Factory.cs +++ b/FluentStorage.Azure.Blobs/Factory.cs @@ -19,6 +19,18 @@ public static IModulesFactory UseAzureBlobStorage(this IModulesFactory factory) return factory.Use(new Module()); } + /// + /// Creates Azure Blob Storage from an existing . + /// + public static IAzureBlobStorage AzureBlobStorage(this IBlobStorageFactory factory, + BlobServiceClient blobServiceClient, + string containerName = null) { + if (blobServiceClient is null) + throw new ArgumentNullException(nameof(blobServiceClient)); + + return new AzureBlobStorage(blobServiceClient, blobServiceClient.AccountName, containerName: containerName); + } + /// /// Connect to local emulator /// From 1c4d319fd6d8668f5861b806f991bc462ddb776d Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Mon, 30 Mar 2026 15:06:25 +0200 Subject: [PATCH 2/2] Fix Codacy issues: use overloads instead of optional param, add braces --- FluentStorage.Azure.Blobs/Factory.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/FluentStorage.Azure.Blobs/Factory.cs b/FluentStorage.Azure.Blobs/Factory.cs index 126bb6f..fdaf946 100644 --- a/FluentStorage.Azure.Blobs/Factory.cs +++ b/FluentStorage.Azure.Blobs/Factory.cs @@ -19,14 +19,23 @@ public static IModulesFactory UseAzureBlobStorage(this IModulesFactory factory) return factory.Use(new Module()); } + /// + /// Creates Azure Blob Storage from an existing . + /// + public static IAzureBlobStorage AzureBlobStorage(this IBlobStorageFactory factory, + BlobServiceClient blobServiceClient) { + return AzureBlobStorage(factory, blobServiceClient, null); + } + /// /// Creates Azure Blob Storage from an existing . /// public static IAzureBlobStorage AzureBlobStorage(this IBlobStorageFactory factory, BlobServiceClient blobServiceClient, - string containerName = null) { - if (blobServiceClient is null) + string containerName) { + if (blobServiceClient is null) { throw new ArgumentNullException(nameof(blobServiceClient)); + } return new AzureBlobStorage(blobServiceClient, blobServiceClient.AccountName, containerName: containerName); }