Skip to content

Commit c053311

Browse files
Add examples to composer
1 parent e7db735 commit c053311

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/Umbraco.StorageProviders.AzureBlob.TestSite/AzureBlobFileSystemComposer.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Azure.Core;
2+
using Azure.Storage.Blobs;
13
using Microsoft.Extensions.Options;
24
using Umbraco.Cms.Core.Composing;
35
using Umbraco.Cms.Core.Events;
@@ -8,10 +10,25 @@ namespace Umbraco.StorageProviders.AzureBlob.TestSite;
810

911
internal sealed class AzureBlobFileSystemComposer : IComposer
1012
{
13+
private static readonly BlobClientOptions _blobClientOptions = new BlobClientOptions
14+
{
15+
Retry = {
16+
Mode = RetryMode.Exponential,
17+
MaxRetries = 3
18+
}
19+
};
20+
1121
public void Compose(IUmbracoBuilder builder)
1222
=> builder
13-
.AddAzureBlobMediaFileSystem()
23+
// Add using default options (overly verbose, but shows how to revert back to the default)
24+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingDefault())
25+
// Add using options
26+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingOptions(_blobClientOptions))
27+
// If the connection string is parsed to a URI, use the delegate to create a BlobContainerClient
28+
.AddAzureBlobMediaFileSystem(options => options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, _blobClientOptions)))
29+
// Add the ImageSharp IImageCache implementation using the default media file system and "cache" container root path
1430
.AddAzureBlobImageSharpCache()
31+
// Add notification handler to create the media file system on install if it doesn't exist
1532
.AddNotificationHandler<UnattendedInstallNotification, AzureBlobMediaFileSystemCreateIfNotExistsHandler>();
1633

1734
private sealed class AzureBlobMediaFileSystemCreateIfNotExistsHandler : INotificationHandler<UnattendedInstallNotification>

0 commit comments

Comments
 (0)