The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Azure App Service - Web Apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
Unable to delete file from Azure webjob directory RRS feed

  • Question

  • I have a continuous webjob that runs WinSCP.exe to do some SFTP tasks. The WinSCP.exe file exists in the webjob directory: D:\home\site\wwwroot\app_data\jobs\continuous\WEBJOB_NAME\WinSCP.exe

    Problem first appeared when I tried to deploy. Got this error: 

    Error: Error Code: ERROR_FILE_IN_USE
    More Information: Web Deploy cannot modify the file 'WinSCP.exe' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.

    Disabled the webjob in portal, tried again. Get this error now:

    Error: Error Code: ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER More Information: Unable to perform the operation ("Create File") for the specified directory ("D:\home\site\wwwroot\app_data\jobs\continuous\WEBJOB_NAME\WinSCP.exe"). This can occur if the server administrator has not authorized this operation for the user credentials you are using.

    Many other sizes were able to deploy successfully using the exact same deployment flow.

    I have tried everything from this article:  https://github.com/projectkudu/kudu/wiki/Dealing-with-locked-files-during-deployment 

    I can delete all other files in the webjob directory from the kudu console.

    I have checked running processes in kudu and WinSCP.exe does not show up in either of 2 site instances. I have killed all running processes, restarted the site, fully stopped the site and scm, still can't delete the file. Runing the "attrib" command shows the "A" so it's not read-only.

    Totally stumped at this point. 


    • Edited by JosiahM Wednesday, October 16, 2019 5:28 AM
    Wednesday, October 16, 2019 5:22 AM

All replies

  • are you able to rename it?   also check the env for WEBSITE_VOLUME_TYPE whether it is PrimaryStorageVolume or SecondaryStorageVolume?   

    Suwatch

    Wednesday, October 16, 2019 7:14 AM
  • Cannot rename: "Rename-Item : Access to the path is denied."

    WEBSITE_VOLUME_TYPE is PrimaryStorageVolume


    Wednesday, October 16, 2019 4:32 PM
  • OK .. we need more info the help.  Provide sitename here or indirectly.   Issue is on going, correct?   Please acknowledge if we can go ahead remove/rename the file D:\home\site\wwwroot\app_data\jobs\continuous\WEBJOB_NAME\WinSCP.exe for you?   We assume you have a backup.   

    Suwatch

    Thursday, October 17, 2019 7:46 AM
  • Yes the issue is ongoing. And yes please remove the WinSCP.exe file, I do have a backup. Partial site info below. 

    Subscription ID: 3cb2...6b80

    Sitename: lif...es.azurewebsites.net

    Webjob Directory: D:\home\site\wwwroot\app_data\jobs\continuous\Im...rt\

    In the webjob directory added a file help.txt with this information.

    Thank you. 

    Thursday, October 17, 2019 5:23 PM
  • Thanks for the info .. we are working on it.

    Suwatch

    Friday, October 18, 2019 11:15 PM
  • File (WinSCP.exe) is now deleted.   BTW, if you were to stop and start the site - it should do the trick.

    Suwatch

    • Proposed as answer by Rahber Sunday, October 20, 2019 9:20 AM
    Friday, October 18, 2019 11:54 PM
  • Ok great thank you.

    And yeah I did stop and start a couple times it never freed the file up. 🤷‍♂️

    Friday, October 18, 2019 11:57 PM