31

I have been deploying to my Azure Web App for about 4 months now, using msdeploy, and everything has been smooth sailing to upload the website. Until recently, there has been no errors with deployment. I now receive a "ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER" error when publishing the website application.

The only way for me to successfully update the website is stop the Web App on Azure, then execute a Publish for the Web Application via Visual Studio. But this can be an issue if users are currently using the system. I don't really want any downtime while updating the website.

The full error is as follows:

msdeploy error ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER: Web deployment task failed. (Unable to perform the operation ("Create File") for the specified directory ("D:\home\site\ wwwroot\bin\Domain.DbFactory.dll"). This can occur if the server administrator has not authorized this operation for the user credentials you are using. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER.)

How would I go about authorising these permissions?

I have also reset my publishing profile on Azure, and downloaded a fresh profile to attempt it again. But no luck with that.

10 Answers 10

35

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
5
  • Hi, it would happen with any of the published files to that web app. Whether it be a "Create" permission denied, or in the case of removing remote files on publish it would be a "Delete" permission denied. However, your advice has helped me manage the web app with the Kudu Console and get it going again by renaming the files. Thanks very much. Jan 6, 2016 at 8:24
  • 6
    You can also Stop the website in the Azure Portal before publishing it, and restart it after. Of course the website will be unavailable but that can be an option during development.
    – Costo
    Mar 16, 2016 at 15:29
  • I just had this issue. Despite complaining about the file on the remote Azure server, simply restarting VS fixed the problem. Nov 22, 2017 at 15:22
  • @Costo I stop website but same issue. Finally removed file from Kudu debug Console Mar 23, 2020 at 17:03
  • None of the solutions here helped me. The solution was instead to deploy to a new slot and then swap it into the production slot.
    – mbesso
    Jan 11, 2022 at 15:21
33

For me the fix was to set the Remove additional files at destination setting to true.

I am on .NET 6 and just recently migrated from .NET Core 3.1 to .NET 6

enter image description here

4
  • Yes this worked for me too.
    – coderguy
    Dec 16, 2021 at 14:50
  • Exact same scenario here. This worked!.. but why? Is it required for subsequent publishing? I had static content that needed to be copied out of the folder before publishing as it deleted this folder upon publishing. Then copied the data back in.
    – GisMofx
    Mar 2, 2022 at 1:49
  • 1
    Yes this worked. Makes sense because I deployed a completely different project and files to the same app service.
    – Andrew
    Dec 3, 2022 at 16:31
  • 1
    This is working...BUT! BE CAREFUL!!!!!!!! This will REMOVE EVERYTHING on the server, what is not on your PC. If there are for example pictures in wwwroot which your user is uploading, they will be GONE. So make sure, You have copied/backuped ABSOLUTELY everything before doing that!!!!
    – Ariteku
    2 days ago
3

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.

0
2

I got the error (Unable to perform the operation ("Delete Directory") for the specified directory ("2_0_50727") on a deployment that had been working fine and suddenly broke.

If you're not paying attention '2_0_50727' looks like just a random number.

It turns out it was the folder aspnet_client\system_web\2_0_50727 which didn't even contain any files.

Based on the timestamp of this folder - and the fact that it was in ALL my web applications with this timestamp - it must have been created by Add / Remove Features when I made some changes to my IIS installed features. So whatever permissions that runs at is what this folder was created as.

As soon as I deleted it I was able to deploy again.

1
  • So make sure to check all your web apps for this - probably all virtual directories that are applications too Apr 21, 2017 at 22:05
2

It was happening for me too when I was deploying from Octopus to an Azure Web App by stopping the instance. But the w3wp scm process was still using the file. So I had to kill it by going to Process Explorer.

Before killing it search the process which is using the file by searching from File Handle

0

Happens to me when I was messing up with App Service files through FTP. I probably deleted something important. Refreshing and restarting the App Service helped.

0

Mine was complaining about not being able to delete D:\home\site\wwwroot\newrelic\Extensions\JetBrains.Annotations.dll.

I couldn't delete it from Powershell in Kudu even after stopping the web app.

I had to update the the deployment pipeline with -enableRule:DoNotDeleteRule: enter image description here

0

This happened to me when the IIS World Wide Web Publishing Service service had quit running on my server; I had to turn it back on manually.

0

In our case (an Azure function app) the error was due to the app being in a failed state. Apparently some log storage with the error doesn't allow for redeploying the app. Deleting the storage record should resolve the issue, but in our case wasn't necessary since it started working again after some time.

0

I ran into this same issue and the reason for failing is because WEBSITE_RUN_FROM_PACKAGE=1 is set in the Environmental Variables of the app. Once I removed that, I was able to deploy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.