Access denied error when my Azure Website is shutting down (removing cache items)

JHaleZir

New Member
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 : \[code\]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)\[/code\]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 : \[code\]HttpContext.Current.Cache[myKey] = something\[/code\] and I have not define any specific callback like \[code\]CacheItemRemovedCallback\[/code\]. 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 !
 
Back
Top