Sitecore Azure が Microsoft Azure 環境で不適切なファイル システム権限を設定する


解説

Sitecore Azureモジュールを使用してEditing FarmまたはDelivery Farmへの通常のデプロイを実行すると、Sitecoreのアプリケーション プールに使用されるネットワーク サービスIDの、Azure環境におけるファイル システムのアクセス許可が、正しく設定されません。 その結果、「アクセスが拒否されました」というエラーが発生する場合があります。以下はその例です:

エラー #1:

[UnauthorizedAccessException: Access to the path 'E:\approot\UTI\css\combinedMain.css' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   SquishIt.Framework.Files.RetryableFileOpener.OpenTextStreamWriter(String filePath, Int32 retry, Boolean append)
   SquishIt.Framework.Files.FileWriterFactory.GetFileWriter(String file)
   SquishIt.Framework.Renderers.FileRenderer.WriteFiles(String output, String outputFile)
   SquishIt.Framework.Base.BundleBase`1.RenderRelease(String key, String renderTo, IRenderer renderer)
   Web.UTI.Layouts.Home.Page_Load(Object sender, EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

エラー #2:

ERROR Exception in alarm clock event subscriber.
Exception: System.UnauthorizedAccessException
Message: Access to the path 'E:\approot\App_Data\Submit Queue\0000000006' is denied.
Source: mscorlib
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Sitecore.Analytics.Data.DataAccess.SubmitQueue.FileSubmitQueue.GetDequeueingStream()
   at Sitecore.Data.DataProviders.Retryer.Execute[T](Func`1 action, Action recover)
   at Sitecore.Analytics.Data.DataAccess.SubmitQueue.FileSubmitQueue.Dequeue()
   at Sitecore.Analytics.SubmitQueueService.WakeUp()
   at Sitecore.Services.AlarmClock.Heartbeat_Beat(Object sender, EventArgs e)

エラー #3:

ERROR Could not update device detection database
Exception: System.Net.WebException
Message: An exception occurred during a WebClient request.
Source: System
   at System.Net.WebClient.DownloadFile(Uri address, String fileName)
   at Sitecore.CES.DeviceDetection.Netbiscuits.DeviceDetectionClient.Downloader.Download(String databaseLink, String targetPath)
   at Sitecore.CES.DeviceDetection.Netbiscuits.DeviceDetectionClient.Update()
Nested Exception
Exception: System.UnauthorizedAccessException
Message: Access to the path 'E:\approot\App_Data\DeviceDetection\DeviceDetectionDB-20160413.db' is denied.
Source: mscorlib
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at System.Net.WebClient.DownloadFile(Uri address, String fileName)

この問題は、Azure モジュール3.0以降のバージョンに影響します。

解決策

この問題を解決するには、次の手順を実行します:

  1. 以下に示すように、\App_Data\AzureOverrideFiles\bin\Startup.cmdスクリプトを変更します:
    IF "%ComputeEmulatorRunning%" == "true" (
    :: do not remove the echo string or else you will get an exception
    ECHO  ComputeEmulatorRunning environment
    ) ELSE (
    ECHO Azure environment
    CACLS ../../approot /t /e /p "Network Service":c %windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00 ) EXIT /b 0
  2. Sitecore Azureアプリケーションで、既存のEditing FarmまたはDelivery Farmに対してファイルのアップグレードを実行します。