Azure Web App Deployment error via msdeploy - ERROR_INSUFFICIENT_A CCESS_TO_SITE_FOLDER

The error is a bit deceiving. This likely has nothing to do with permission, but is instead caused by files being in use.

Does it always happen with Gehs.DbFactory.dll, or is it sometimes other files? Also, is Gehs.DbFactory.dll a regular managed assembly, or native/mixed assembly?

Normally, all assemblies get shadow copied, so they are not locked in the bin folder. If if it's native, it could end up getting loaded in place.

Note that if that's the case, it's not Azure specific, and you'd likely have the same issue deploying anywhere. e.g. try deleting this file from your bin folder while running locally.

One way or another, you need to make sure that no file gets locked in place if you want to publish newer version.

If you can't find a way to do this, here is a technique that should let you publish without any downtime:

  • using Kudu Console, go to your d:\home\site\wwwroot\bin folder
  • Renaming the offending DLL, e.g. to Gehs.DbFactory.dll.old (renaming normally works even if you can't delete it)
  • Do your publishing

Same thing was happening to me when I added a new folder under Content in my project and then tried to publish. I just restarted the app on Azure and then it worked fine.