Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sven 34 posts 138 karma points
    Jun 08, 2023 @ 09:23
    Sven
    0

    Azure Blob Storage for Media and Image Processor Cache

    Hello!

    Question about using azure blob storage for media & image processor cache in an umbraco v8.14 project hosted on azure.

    We used this guide https://our.umbraco.com/documentation/Extending/FileSystemProviders/Azure-Blob-Storage/ in combination with the 'azure blob cache' https://imageprocessor.org/imageprocessor-web/plugins/azure-blob-cache/ guide to setup the azure blob storage connection.

    We noticed some performance issues going on with the media files and on further investigation (using azure application insights) I noticed that a lot of media requests are really slow.

    I therefore suspect that something is wrong somewhere in our configuration, but I can't figure out what could be wrong ...

    • Umbraco v8.14.1
    • ImageProcessor.Web.Plugins.AzureBlobCache v1.7.1
    • ImageProcessor.Web.Config v2.6.0
    • ImageProcessor.Web v4.11.0
    • ImageProcessor.Plugins.WebP v.1.3.0
    • ImageProcessor v2.8.0

    cache.config:

    <?xml version="1.0" encoding="utf-8"?>
    <caching currentCache="AzureBlobCache">
        <caches>
            <cache name="AzureBlobCache" type="ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache, ImageProcessor.Web.Plugins.AzureBlobCache" maxDays="1" browserMaxDays="1" folderDepth="6" trimCache="true" memoryMaxMinutes="1">
                <settings>
                    <setting key="CachedStorageAccount" value="DefaultEndpointsProtocol=https;AccountName=[storageaccountname];AccountKey=[accountkey]" />
                    <setting key="CachedBlobContainer" value="cache" />
                    <setting key="UseCachedContainerInUrl" value="true" />
                    <setting key="CachedCDNRoot" value="" />
                    <setting key="CachedCDNTimeout" value="1000" />
                    <setting key="SourceStorageAccount" value="" />
                    <setting key="SourceBlobContainer" value="" />
                    <setting key="StreamCachedImage" value="false" />
                </settings>
            </cache>
        </caches>
    </caching>
    

    Security.config:

    <?xml version="1.0" encoding="utf-8"?>
    <security>
        <services>
            <service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
                <settings>
                    <setting key="Container" value="media" />
                    <setting key="MaxBytes" value="65554432" />
                    <setting key="Timeout" value="30000" />
                    <setting key="Host" value="https://[storagename].blob.core.windows.net/" />
                </settings>
            </service>
            <service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
                <settings>
                    <setting key="MaxBytes" value="4194304" />
                    <setting key="Timeout" value="3000" />
                    <setting key="Protocol" value="https" />
                </settings>
                <whitelist>
                </whitelist>
            </service>
        </services>
    </security>
    

    In our web.config we added all the information like this:

      <add key="AzureBlobFileSystem.ContainerName:media" value="media" />
      <add key="AzureBlobFileSystem.RootUrl:media" value="https://[myAccountName].blob.core.windows.net/" />
      <add key="AzureBlobFileSystem.ConnectionString:media"
        value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
      <add key="AzureBlobFileSystem.MaxDays:media" value="365" />
      <add key="AzureBlobFileSystem.UseDefaultRoute:media" value="true" />
      <add key="AzureBlobFileSystem.UsePrivateContainer:media" value="false" />
    
    <?xml version="1.0"?>
    <configuration>
      <location path="Media">
        <system.webServer>
        <handlers>
            <remove name="StaticFileHandler" />
            <add name="StaticFileHandler" path="*" verb="*"
                preCondition="integratedMode" type="System.Web.StaticFileHandler" />
        </handlers>
        </system.webServer>
      </location>
    </configuration>
    

    Errors from logviewer:

    System.UriFormatException: Invalid URI: The format of the URI could not be determined.
       at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
       at System.Net.WebRequest.Create(String requestUriString)
       at ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.RewritePath(HttpContext context)
       at ImageProcessor.Web.HttpModules.ImageProcessingModule.<ProcessImageAsync>d__31.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
       at System.Web.HttpApplication.AsyncEventExecutionStep.<>c__DisplayClass11_0.<InvokeEndHandler>b__0()
       at System.Web.HttpApplication.AsyncEventExecutionStep.InvokeEndHandler(IAsyncResult ar)
       at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
    

    Any ideas? Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft