2016-10-05 31 views
1

這些圖像可以在本地ENV中加載,也可以在生產ENV中加載。但是,無論如何,暫存環境無法加載這些內容。ImageProcessor/Windows Azure存儲問題,返回403 Forbidden

<package id="ImageProcessor" version="2.2.0.0" targetFramework="net45" /> 
    <package id="ImageProcessor.Web" version="4.2.1.0" targetFramework="net45" /> 
    <package id="ImageProcessor.Web.Config" version="2.2.0.0" targetFramework="net45" /> 
    <package id="ImageProcessor.Web.Plugins.AzureBlobCache" version="1.0.0.0" targetFramework="net45" /> 
    <package id="ImageProcessor.Web.PostProcessor" version="1.0.2.0" targetFramework="net45" /> 
    <package id="UmbracoAzureBlobStorageProvider" version="1.0.10.5" targetFramework="net45" /> 
    <package id="WindowsAzure.Storage" version="4.3.0" targetFramework="net45" /> 

我使用ImageProcessor並根據需要域列入白名單:

<whitelist> 
     <add url="http://conceptjp.blob.core.windows.net/"/> 
     <add url="https://az739977.vo.msecnd.net/"/> 
</whitelist> 

https://staging.conceptjp.com/remote.axd?https://az739977.vo.msecnd.net/media/6883/logo-sparitual.png?quality=70(沒有工作)

https://conceptjp.com/remote.axd?https://az739977.vo.msecnd.net/media/6883/logo-sparitual.png?quality=70(作品)

https://cjp.local/remote.axd?https://az739977.vo.msecnd.net/media/6883/logo-sparitual.png?quality=70(工程,當地環境)

2016-10-04 13:31:11.2393 Logging.TheLogger The remote server returned an error: (403) Forbidden. The remote server returned an error: (403) Forbidden. at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) 
    at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar) 
--- 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 ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.<IsNewOrUpdatedAsync>d__2.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 ImageProcessor.Web.HttpModules.ImageProcessingModule.<ProcessImageAsync>d__10.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 System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) 
    at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) 
+0

答案是將服務器上的時鐘設置爲UTC。 http://stackoverflow.com/questions/22828279/403-error-in-production-from-windowsazure-storage –

回答

8

我不知道該說些什麼。幾乎所有的東西都以我不期望也不推薦的方式使用。

如果您在Azure上使用Umbraco,則應該爲您的媒體使用以下插件。

https://github.com/JimBobSquarePants/UmbracoFileSystemProviders.Azure

FileSystemProvider您使用已經過時了大約一年半的時間。它實際上建議在其主頁上使用上面提到的插件。

新套件UmbracoFileSystemProviders.Azure在線! 請參閱:https://our.umbraco.org/projects/collaboration/umbracofilesystemprovidersazure/

我推薦它來代替這個,特別是如果您使用的是Umbraco 7.3或更高版本。它解決了你在後臺會遇到的很多問題。

https://our.umbraco.org/projects/backoffice-extensions/azure-blob-storage-provider

這樣做的原因是,原來的供應商有缺陷可能無法修復沒有完全重寫。

  1. 媒體使用絕對URL存儲在數據庫中。這意味着相同的媒體不能在多個環境中使用。
  2. 媒體在後臺下載並顯示爲未處理。這導致100 MB的數據被不必要地下載,從而破壞了大型網站的性能。

您必須在數據庫入門之前更換媒體參考,以從存儲的URL中去除域。我個人建議從頭開始重建媒體部分。

GitHub頁面上有全面的說明,但我會在下面列出它們。

首先。卸載舊的插件,更新所有ImageProcessor庫到最新版本,並安裝建議FileSystemProvider插件

然後更新~/Config/FileSystemProviders.config與替換默認提供了以下內容:

<?xml version="1.0"?> 
<FileSystemProviders> 
    <Provider alias="media" type="Our.Umbraco.FileSystemProviders.Azure.AzureBlobFileSystem, Our.Umbraco.FileSystemProviders.Azure"> 
    <Parameters> 
     <add key="containerName" value="media" /> 
     <add key="rootUrl" value="http://[myAccountName].blob.core.windows.net/" /> 
     <add key="connectionString" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]"/> 
     <!-- 
     Optional configuration value determining the maximum number of days to cache items in the browser. 
     Defaults to 365 days. 
     --> 
     <add key="maxDays" value="365" /> 
    </Parameters> 
    </Provider> 
</FileSystemProviders> 

現在需要的CloudImageService配置捕獲與/媒體開始/所有請求

<?xml version="1.0"?> 
<security> 
    <services> 
    <service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/> 
    <service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web"> 
     <settings> 
     <setting key="Container" value="media"/> 
     <setting key="MaxBytes" value="8194304"/> 
     <setting key="Timeout" value="30000"/> 
     <setting key="Host" value="http://[myAccountName].blob.core.windows.net/media"/> 
     </settings> 
    </service> 
    </services> 

確保您的緩存配置設置正確。

<caching currentCache="AzureBlobCache"> 
    <caches> 
    <!-- Disk cache configuration removed for brevity --> 
    <cache name="AzureBlobCache" type="ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache, ImageProcessor.Web.Plugins.AzureBlobCache" maxDays="365"> 
     <settings> 
     <!-- The Account, Container and CDN details --> 
     <setting key="CachedStorageAccount" value="DefaultEndpointsProtocol=https;AccountName=[CacheAccountName];AccountKey=[CacheAccountKey]"/> 
     <setting key="CachedBlobContainer" value="cache"/> 
     <!-- Whether to add the container name to the CDN url. Newer Azure formats require false. --> 
     <setting key="UseCachedContainerInUrl" value="true"/> 
     <!-- Full CDN root url e.g http://123456.vo.msecnd.net/ --> 
     <setting key="CachedCDNRoot" value="[CdnRootUrl]"/> 
     <!-- Optional setting for a timeout limit in milliseconds when attempting to communicate with the CDN url. --> 
     <setting key="CachedCDNTimeout" value="1000"/> 
     <!-- 
      Optional settings for better identifcation of source images if stored in 
      Azure blob storage. 
     --> 
     <setting key="SourceStorageAccount" value=""/> 
     <setting key="SourceBlobContainer" value=""/> 
     <!-- 
      Optional settings facilitate streaming of the blob resource directly instead of a redirect. This is beneficial 
      for CDN purposes but caution should be taken if not used with a CDN as it will add quite a bit of overhead 
      to the site. 
     --> 
     <setting key="StreamCachedImage" value="false"/> 
     </settings> 
    </cache> 
    </caches> 
</caching> 

圖片的請求,現在應該使用根相對/media/路徑僅可在內置在虛擬路徑提供程序將相應地截獲和過程中產生的。

例如/media/1046/car-small.jpg?width=500&height=500&mode=boxpad&bgcolor=hotpink

+0

你認爲這是時間問題之前[https://conceptjp.com]圖像disapear? –

+0

我不明白你在問什麼,我很害怕。 –

+0

@JamesSouth - 我假設他問他是否可以跳過您提供給他的修復的後半部分,並且只是等待人們更新足夠的圖像以使數據庫中沒有絕對URL。 聽起來像很多角落在這裏:\ –