2
votes

After many years of using ImageResizer with the Disk Cache plugin on a dedicated server we are gradually migrating our websites to Microsoft Azure. Unfortunately I'm having problems with the ImageResizer AzureReader2 plugin.

My test images are hosted in an Azure Cloud Storage container. The ImageResizer plugins have been added to a new empty MVC web project using NuGet. If I request the image without a QueryString then the response from ImageResizer is a 302-redirect to the direct blob URL.

e.g.

http://localhost:50505/azure/bhjrbbgljx.jpg -->
https://jetpress.blob.core.windows.net/media/bhjrbbgljx.jpg

However adding the QueryString to perform a resize results in a 404-not found response.

e.g.

http://local.host:50505/azure/bhjrbbgljx.jpg?width=200 --> 404 page

After plenty of searching I haven't been able to uncover anybody else having similar problems. The question Resizing an image using AzureReader2 results in 404 doesn't apply as I am still running on IIS Express through VS2013.

Detailed Error Information

Module
   IIS Web Core 

Notification
   MapRequestHandler 

Handler
   StaticFile 

Error Code
   0x80070002 

Requested URL
   http://localhost:50505/azure/bhjrbbgljx.jpg?width=200 

Physical Path
   E:\projects\Websites.AzureMedia\JETPRESS.Web.Websites.AzureMedia\azure\bhjrbbgljx.jpg 

Logon Method
   Anonymous 

Logon User
   Anonymous 

Request Tracing Directory
   C:\Users\davidc\Documents\IISExpress\TraceLogFiles\JETPRESS.WEB.WEBSITES.AZUREMEDIA 

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="1.8.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <httpModules>
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
    </modules>
  </system.webServer>
  <resizer>
    <diagnostics enableFor="Localhost" />
      <plugins>
        <add name="MvcRoutingShim" />
      <add name="AzureReader2" 
           connectionString="[redacted]" 
           endpoint="https://jetpress.blob.core.windows.net/media/" />
    </plugins>
    </resizer>
</configuration>

resizer.debug

Image resizer diagnostic sheet      20/10/2014 14:38:41

2 Issues detected:

(Warning):  To potentially see additional errors here, perform an image resize request.


(Warning):  NoCache is only for development usage, and cannot scale to production use.
            Add DiskCache or CloudFront for production use


You are using plugins from the Performance Edition: AzureReader2Plugin (Performance Edition)

Registered plugins:

ImageResizer.Plugins.Basic.DefaultEncoder
ImageResizer.Plugins.Basic.NoCache
ImageResizer.Plugins.Basic.ClientCache
ImageResizer.Plugins.Basic.Diagnostic
ImageResizer.Plugins.Basic.SizeLimiting
ImageResizer.Plugins.MvcRoutingShim.MvcRoutingShimPlugin
ImageResizer.Plugins.AzureReader2.AzureReader2Plugin

Configuration:

<resizer>
<diagnostics enableFor="Localhost" />
<plugins>
<add name="MvcRoutingShim" />
<add name="AzureReader2" connectionString="[redacted]" endpoint="https://jetpress.blob.core.windows.net/media/" />
</plugins>
</resizer>


Accepted querystring keys:

quality, format, thumbnail, maxwidth, maxheight, width, height, w, h, scale, stretch, crop, cropxunits, cropyunits, page, bgcolor, rotate, flip, sourceFlip, sFlip, sRotate, borderWidth, borderColor, paddingWidth, paddingColor, ignoreicc, frame, useresizingpipeline, cache, process, margin, anchor, dpi, mode, zoom, 

Accepted file extensions:

bmp, gif, exif, png, tif, tiff, tff, jpg, jpeg, jpe, jif, jfif, jfi, 

Environment information:

Running Microsoft-IIS/8.0 on Microsoft Windows NT 6.1.7601 Service Pack 1 and CLR 4.0.30319.18444
Trust level: Unrestricted
OS bitness: x86 !! Warning, running as 32-bit on a 64-bit OS(AMD64). This will limit ram usage !!
Executing assembly: C:\Program Files (x86)\IIS Express\iisexpress.exe
IntegratedPipeline: True

Loaded assemblies:

mscorlib                                 Assembly: 4.0.0.0         File: 4.0.30319.18444 Info: 4.0.30319.18444
System.Web                               Assembly: 4.0.0.0         File: 4.0.30319.34237 Info: 4.0.30319.34237
System                                   Assembly: 4.0.0.0         File: 4.0.30319.34238 Info: 4.0.30319.34238
System.Core                              Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.ApplicationServices           Assembly: 4.0.0.0         File: 4.0.30319.34237 Info: 4.0.30319.34237
System.Configuration                     Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xml                               Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Runtime.Caching                   Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
Microsoft.Build.Utilities.v4.0           Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
Microsoft.JScript                        Assembly: 10.0.0.0        File: 11.0.50938.18408 Info: 11.0.50938.18408
System.Web.Mvc                           Assembly: 5.2.0.0         File: 5.2.20627.0     Info: 5.2.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.WebPages.Deployment           Assembly: 3.0.0.0         File: 3.0.20627.0     Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.WebPages.Deployment           Assembly: 1.0.0.0         File: 1.0.20105.407  
System.Web.WebPages                      Assembly: 3.0.0.0         File: 3.0.20627.0     Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
Microsoft.VisualStudio.Web.PageInspector.Loader Assembly: 1.0.0.0         File: 12.3.50717.0   
System.Web.WebPages.Deployment           Assembly: 2.0.0.0         File: 2.0.20710.0    
System.Web.WebPages.Razor                Assembly: 3.0.0.0         File: 3.0.20627.0     Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
Microsoft.VisualStudio.Web.PageInspector.Runtime Assembly: 12.3.0.0        File: 12.3.50717.0   
Microsoft.Web.Infrastructure             Assembly: 1.0.0.0         File: 1.0.20105.407  
App_global.asax.tc0cm6e1                 Assembly: 0.0.0.0        
JETPRESS.Web.Websites.AzureMedia         Assembly: 1.0.0.0         File: 1.0.0.0        
System.ServiceModel.Activation           Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Extensions                    Assembly: 4.0.0.0         File: 4.0.30319.34237 Info: 4.0.30319.34237
Microsoft.CSharp                         Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Data                              Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Services                      Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Drawing                           Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.EnterpriseServices                Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.IdentityModel                     Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Runtime.Serialization             Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel                      Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel.Web                  Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Activities                        Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.ServiceModel.Activities           Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.WorkflowServices                  Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Data.DataSetExtensions            Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xml.Linq                          Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.ComponentModel.DataAnnotations    Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.DynamicData                   Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
ImageResizer                             Assembly: 3.4.3.103       File: 3.4.3.103       Info: 3-4-3  Commit: bf92fd7
ImageResizer.Mvc                         Assembly: 3.4.3.103       File: 3.4.3.103       Info: 3-4-3  Commit: bf92fd7
ImageResizer.Plugins.AzureReader2        Assembly: 3.4.3.103       File: 3.4.3.103       Info: 3-4-3  Commit: bf92fd7
Microsoft.Data.Edm                       Assembly: 5.6.2.0         File: 5.6.2.61936     Info: 5.6.2.61936
Microsoft.Data.OData                     Assembly: 5.6.2.0         File: 5.6.2.61936     Info: 5.6.2.61936
Microsoft.Data.Services.Client           Assembly: 5.6.2.0         File: 5.6.2.61936     Info: 5.6.2.61936
Microsoft.WindowsAzure.Configuration     Assembly: 1.8.0.0         File: 1.8.0.0        
Microsoft.WindowsAzure.Storage           Assembly: 4.3.0.0         File: 4.3.0.0        
Newtonsoft.Json                          Assembly: 4.5.0.0         File: 5.0.8.16617    
System.Spatial                           Assembly: 5.6.2.0         File: 5.6.2.61936     Info: 5.6.2.61936
System.Web.Helpers                       Assembly: 3.0.0.0         File: 3.0.20627.0     Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.Web.Razor                         Assembly: 3.0.0.0         File: 3.0.20627.0     Info: 3.0.0-20627 (0adbfd47c58682f25b5ace9732ca9374ed1f9a89)
System.ServiceModel.Internals            Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
System.Web.Routing                       Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Web.Abstractions                  Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
SMDiagnostics                            Assembly: 4.0.0.0         File: 4.0.30319.34234 Info: 4.0.30319.34234
Microsoft.VisualStudio.Web.PageInspector.Tracing Assembly: 12.3.0.0        File: 12.3.50717.0   
System.Web.Mobile                        Assembly: 4.0.0.0         File: 4.0.30319.34237 Info: 4.0.30319.34237
System.Web.RegularExpressions            Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xaml.Hosting                      Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
System.Xaml                              Assembly: 4.0.0.0         File: 4.0.30319.18408 Info: 4.0.30319.18408
1
do you need runallmanagedmodulesforallrequests? seems like without that you might not be able to intercept the request, which is why you are getting a 404Darren Kopp
Does it work if you use the .ashx syntax? localhost:50505/azure/bhjrbbgljx.jpg.ashx?width=200Lilith River
@DarrenKopp Still a 404 but the HTML markup has changed. It looks like it is now being output further up the HTTP pipeline as it references the ASP.NET version. Was it just the IIS static file handler before?cookdn
Do you have some kind of URL rewriting going on? If so, could you post the code?Lilith River
@ComputerLinguist Effectively the same as the modification suggested by Darren Kopp. Still a 404 but looks a request to the handler using the .ashx extension is now being handled further up the HTTP pipeline (I did test these changes separately).cookdn

1 Answers

3
votes

AzureReader2 expects paths in the form /azure/container/blob

You can change the /azure prefix via the prefix="~/path" attribute when installing the plugin. However, in order to drop the container name from the URL, you will need to use URL rewriting.

Currently, you have both an invalid endpoint and an invalid path.

endpoint="https://jetpress.blob.core.windows.net/media/" path: /azure/bhjrbbgljx.jpg

These should, instead, be

endpoint="https://jetpress.blob.core.windows.net/" path: /azure/media/bhjrbbgljx.jpg

The redirect worked by coincidence of concatenation; this, I believe, threw you off the trail of the true issue.