0

My app is working well on Azure Websites (not Web role, please exclude web role specific answers !), but sometimes I got the following error in my logs :

System.UnauthorizedAccessException: Access to the path 'C:\DWASFiles\Sites\myAzureWebSiteNameHere\VirtualDirectory0\site\wwwroot' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.EnumerateFiles(String path)
   at System.Web.WebPages.Deployment.WebPagesDeployment.AppRootContainsWebPagesFile(String path)
   at System.Web.WebPages.Deployment.PreApplicationStartCode.OnChanged(String key, Object value, CacheItemRemovedReason reason)
   at System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(CacheItemRemovedCallback callback, CacheItemRemovedReason reason)

This happened just before the site is restarted (by Azure, not by me, probably for a maintenance operation on the VM containing the site). So I concluded that it happened during a "shutting down" operation, when the system try to clear the cache.

I'm using the Asp.net cache like this : HttpContext.Current.Cache[myKey] = something and I have not define any specific callback like CacheItemRemovedCallback. The above callstack confirms the error is on a system callback.

It seems to be Azure specific (and perhaps even specific to Azure Websites), because the same website on an on-premise server never had this kind of error.

Do you know how to prevent this error from happening ? Thanks !

John Saunders
  • 160,644
  • 26
  • 247
  • 397
JYL
  • 8,228
  • 5
  • 39
  • 63
  • Not really an answer, but have you considered using Azure distributed caching (co-located or shared)? (high availability on those caches would prevent this). Also it looks like from your error you are getting an unauthorized access exception to the root path. – Bart Czernicki Mar 23 '13 at 04:53
  • @BartCzernicki Dedicated Cache is not supported by Azure Websites – Igorek Mar 23 '13 at 06:07
  • @JYL What cache provider are you using? – Igorek Mar 23 '13 at 06:08
  • @Igorek The default one : I have nothing specific to the cache in my `web.config`. – JYL Mar 23 '13 at 12:20
  • FYI, this error happened many time during March but didn't happened anymore since 03/23. I'll delete my question if it doesn't appear anymore in the next weeks. Probably an update of the Azure Websites team. – JYL Apr 05 '13 at 14:42

0 Answers0