umbraco / Umbraco.StorageProviders

MIT License
29 stars 21 forks source link

Same version working a week ago no longer working #17

Closed drbldgtl closed 3 years ago

drbldgtl commented 3 years ago

Hi all,

Several days ago (last Wednesday or so) blob storage was working per the instructions in https://github.com/umbraco/Umbraco.StorageProviders#readme

Suddenly, today, this is no longer working. Despite no version, configuration or code changes, media is now being stored on the file system.

I've checked csproj and the same version is there <PackageReference Include="Umbraco.StorageProviders.AzureBlob" Version="1.0.0" />

    "Umbraco": {
        "Storage": {
            "AzureBlob": {
                "Media": {
                    "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxx;EndpointSuffix=core.windows.net",
                    "ContainerName": "media"
                }
            }
        },

Configuration copied from appsettings and matches the copy/paste configuration from Azure. Container name the same.

            services.AddUmbraco(_env, _config)
                .AddAzureBlobMediaFileSystem()
                 .AddBackOffice()
                 .AddWebsite()
                 .AddComposers()
                 .Build();

And

            app.UseRouting();
            app.UseImageSharp();
            app.UseStaticFiles();
            app.UseUmbraco()
                 .WithMiddleware(u =>
                 {
                     u.UseBackOffice();
                     u.UseWebsite();
                     u.UseAzureBlobMediaFileSystem();
                 })...

I have not specified .AddCdnMediaUrlProvider() but that is listed as optional.

We DO have a validator for height/width to mitigate querystring manipulation but this is returning OK as it was before (unlikely to be relevant but included for completeness).

        // ImageSharp
        services.AddImageSharp(
             options =>
             {
                 options.OnParseCommandsAsync = c =>
                     {
                         var imageSharpValidator = new ImageSharpValidator();
                         return imageSharpValidator.Validate(c);
                     };
             });

However, I have commented this out with the same result.

I can't see a reason why this would have stopped working, and as far as I can find nothing has changed in terms of how Azure might be dealing with how images might be being written to Azure storage.

Can anyone think of a reason why I might be encountering this issue?

Thanks.

ronaldbarendse commented 3 years ago

@drbldgtl I can see two potential issues:

You can add the custom OnParseCommandsAsync using:

builder.Services.Configure<ImageSharpMiddlewareOptions>(options =>
{
    options.OnParseCommandsAsync = c =>
    {
        var imageSharpValidator = new ImageSharpValidator();
        return imageSharpValidator.Validate(c);
    };
});

Also note that using this custom callback will override the default one Umbraco sets that removes width/height parameters that exceed the configured maximums...