Search code examples
azureazure-blob-storageimageresizer

Image resizer with azure blob storage. Returns "403 forbidden" when going through the resizer


We have been using image resizer with azurereader2 for quite a while with no problem. After a small release (that really shouldnt have anything to do with this) we suddenly get errors when we try to access the images through the resizer.

This is only a problem on our test environment, the new release and image resizer etc. works just fine in production. Both production and test is hosted in azure, and both use their own azure blob storage.

example url: test.mysite.com/images/pim/b6ffa894-bc8f-4f1b-a1e8-ef115b78a56f.jpg?width=250&height=312&format=jpg&scale=both&mode=pad

returns the following error

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.cs:line 50
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.c__DisplayClass13.b__12(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlobClient.cs:line 788
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 299
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 50
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.EndGetBlobReferenceFromServer(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlobClient.cs:line 630
   at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.c__DisplayClass1`1.b__0(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 66
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ImageResizer.Plugins.AzureReader2.AzureReader2Plugin.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ImageResizer.Util.AsyncUtils.RunSync[TResult](Func`1 func)
   at ImageResizer.Storage.Blob.Open() in C:\projects\resizer\Plugins\ImageResizer.Storage\Blob.cs:line 41
   at ImageResizer.ImageBuilder.GetStreamFromSource(Object source, ResizeSettings settings, Boolean& disposeStream, String& path, Boolean& restoreStreamPosition)
   at ImageResizer.ImageBuilder.LoadImage(Object source, ResizeSettings settings, Boolean restoreStreamPos)
   at ImageResizer.ImageBuilder.BuildJob(ImageJob job)
   at ImageResizer.ImageBuilder.Build(ImageJob job)
   at ImageResizer.ImageBuilder.Build(Object source, Object dest, ResizeSettings settings, Boolean disposeSource, Boolean addFileExtension)
   at ImageResizer.ImageBuilder.Build(Object source, Object dest, ResizeSettings settings, Boolean disposeSource)
   at ImageResizer.ImageBuilder.Build(Object source, Object dest, ResizeSettings settings)
   at ImageResizer.InterceptModule.c__DisplayClass5_0.b__1(Stream stream)
   at ImageResizer.Plugins.DiskCache.CustomDiskCache.c__DisplayClass28_0.b__0()
   at ImageResizer.Plugins.DiskCache.LockProvider.TryExecute(String key, Int32 timeoutMs, LockCallback success)
   at ImageResizer.Plugins.DiskCache.CustomDiskCache.GetCachedFile(String keyBasis, String extension, ResizeImageDelegate writeCallback, Int32 timeoutMs, Boolean asynchronous)
   at ImageResizer.Plugins.DiskCache.DiskCache.Process(IResponseArgs e)
   at ImageResizer.Plugins.DiskCache.DiskCache.Process(HttpContext context, IResponseArgs e)
   at ImageResizer.InterceptModule.HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf)
   at XXX.Web.Modules.CustomImageResizingInterceptModule.HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf) in E:\TeamCity\buildAgent\work\4773e55a378b97a1\src\Portal\Portal\Infrastructure\Web\Modules\CustomImageResizingInterceptModule.cs:line 15
   at ImageResizer.InterceptModule.CheckRequest_PostAuthorizeRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Request Information
RequestID:e8c13071-0001-00c2-437e-d8b9c7000000
RequestDate:Mon, 29 May 2017 13:19:16 GMT
StatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

the url test.mysite.com/images/pim/b6ffa894-bc8f-4f1b-a1e8-ef115b78a56f.jpg correctly redirects to the image in the azure blob.

I have tried regenerating the access key for the blob storage, without any luck.
I have tried pointing to another blob storage from our test env, that does not work either.

I can access the test blob storage just fine from my local environment.

/resizer.debug reports 0 issues detected.

Any help is greatly appreciated, let me know if i can provide additional info.


Solution

  • This is purely a azure blob storage connection problem, image resizer is not the culprit.