Cannot get AzureBlobStorageImageProvider to work #122
-
I'm trying the middleware to cache images, and was able to successfully get local files cached to a "different-cache" folder, but when I try to get it to work with my Azure Blob Storage... it doesn't seem to work. Here's my implementation: services.AddImageSharp(
options =>
{
// You only need to set the options you want to change here.
options.Configuration = SixLabors.ImageSharp.Configuration.Default;
options.MaxBrowserCacheDays = 7;
options.MaxCacheDays = 30;
})
.SetRequestParser<QueryCollectionRequestParser>()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = azureStorageConnection,
ContainerName = "temp"
});
})
.AddProvider<AzureBlobStorageImageProvider>()
.AddProcessor<ResizeWebProcessor>()
.AddProcessor<FormatWebProcessor>()
.AddProcessor<BackgroundColorWebProcessor>(); Where "azureStorageConnection" is in the format of: DefaultEndpointsProtocol=https;AccountName=storageaccount;AccountKey=accountKey;BlobEndpoint=https://storageaccount.blob.core.windows.net/;TableEndpoint=https://storageaccount.table.core.windows.net/;QueueEndpoint=https://storageaccount.queue.core.windows.net/;FileEndpoint=https://storageaccount.file.core.windows.net/ Then, if I try:
It returns the full sized image. So, I don't know what exactly I'm doing wrong and would love to get it to work correctly as it would be so extremely useful! Any help would be greatly appreciated! Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @ajtatum There's two issues with your current configuration but first I suggest we grab the latest version from MyGet as the registration API has been improved somewhat and is the same as the final release. First install these specific versions: https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Web/1.0.0-rc.3.15 Then you need to register your provider. services.AddImageSharp(options =>
{
options.BrowserMaxAge = TimeSpan.FromDays(7);
options.CacheMaxAge = TimeSpan.FromDays(30);
})
.ClearProviders()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = "YOUR_CONNECTION_STRING",
ContainerName = "temp"
});
})
.AddProvider<AzureBlobStorageImageProvider>()
.AddProvider<PhysicalFileSystemProvider>(); By default ImageSharp.Web will register the Finally requests are made in the following manner.
Request urls should always be rooted at your site domain. By directing your request outside the domain you are bypassing the middleware. I hope that all makes sense. |
Beta Was this translation helpful? Give feedback.
-
Got it working, thank you! I have another question, but I'll post it in another thread. |
Beta Was this translation helpful? Give feedback.
Hi @ajtatum
There's two issues with your current configuration but first I suggest we grab the latest version from MyGet as the registration API has been improved somewhat and is the same as the final release.
First install these specific versions:
(Note Nuget will detect that the version numbers are lower than the Nuget RC, this is due to invalid version number generation by the tool we previously used to generate version numbers. These are 15 builds ahead!)
https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Web/1.0.0-rc.3.15
https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Web.Providers.Azure/1.0.0-rc.3.15
Then you need to register your provider.