Skip to content

Commit 9123f86

Browse files
Add documentation for custom blob container options
1 parent 29bfe44 commit 9123f86

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,36 @@ UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=sample-container
107107
> **Note**
108108
> You still have to add the provider in the `Program.cs` file when not configuring the options in code.
109109
110+
### Custom blob container options
111+
To override the default blob container options, you can use the following extension methods on `AzureBlobFileSystemOptions`:
112+
```csharp
113+
// Add using default options (overly verbose, but shows how to revert back to the default)
114+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingDefault())
115+
// Add using options
116+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingOptions(_blobClientOptions))
117+
// If the connection string is parsed to a URI, use the delegate to create a BlobContainerClient
118+
.AddAzureBlobMediaFileSystem(options => options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, _blobClientOptions)))
119+
```
120+
121+
This can also be used together with the `Azure.Identity` package to authenticate with Azure AD (using managed identities):
122+
```csharp
123+
using Azure.Identity;
124+
using Azure.Storage.Blobs;
125+
using Umbraco.Cms.Core.Composing;
126+
using Umbraco.StorageProviders.AzureBlob.IO;
127+
128+
internal sealed class AzureBlobFileSystemComposer : IComposer
129+
{
130+
public void Compose(IUmbracoBuilder builder)
131+
=> builder.AddAzureBlobMediaFileSystem(options =>
132+
{
133+
options.ConnectionString = "https://[storage-account].blob.core.windows.net";
134+
options.ContainerName = "media";
135+
options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, new DefaultAzureCredential()));
136+
});
137+
}
138+
```
139+
110140
## Umbraco.StorageProviders.AzureBlob.ImageSharp
111141
Adds ImageSharp support for storing the image cache to a pre-configured Azure Blob Storage provider.
112142

0 commit comments

Comments
 (0)