admin管理员组

文章数量:1122832

I am running an Azure App Service that deploys a container app. I enabled persistent storage so I can store some database data. The service is in the stopped state and now I wanted to remove the folder using the rm -rf myfolder command. However I get the error myfolder is not an empty Directory

I guess there is still some file lock on this folder since the recursive command should properly delete this folder. But as the service is in the stopped state and the command set in the Kudu Console is limited, what can I do to forcefully delete this folder or free the locks?

I am running an Azure App Service that deploys a container app. I enabled persistent storage so I can store some database data. The service is in the stopped state and now I wanted to remove the folder using the rm -rf myfolder command. However I get the error myfolder is not an empty Directory

I guess there is still some file lock on this folder since the recursive command should properly delete this folder. But as the service is in the stopped state and the command set in the Kudu Console is limited, what can I do to forcefully delete this folder or free the locks?

Share Improve this question asked Nov 22, 2024 at 15:44 WJMWJM 1,1811 gold badge15 silver badges30 bronze badges 5
  • Have you tried deleting the files inside the folder and then delete the folder? @WJM – Jahnavi Commented Nov 24, 2024 at 12:28
  • Yes, same problem there, subfolders indicate Directory is not empty – WJM Commented Nov 24, 2024 at 16:41
  • Checking on it. @WJM – Jahnavi Commented Nov 25, 2024 at 3:33
  • Can you check if this is the similar one you are looking for? @WJM – Jahnavi Commented Nov 25, 2024 at 14:49
  • Have you tried using web jobs by any chance? @WJM – Jahnavi Commented Nov 26, 2024 at 9:55
Add a comment  | 

1 Answer 1

Reset to default 1

It is possible that the file locks might block the directory deletion in kudu of an app service and also check you have necessary permissions to access the Kudu console and delete them.

The main reason could be due to the files in Kudu is that the files are used by running process with your app service application. In that scenario, try to kill the running process first and then delete the specific folders.

Also check the app setting WEBSITE_RUN_FROM_PACKAGE to 0 to delete all the root directory folders or files.

Refer SO by @Jason Pan for more relevant information on your issue.

If still the persists, check if there are any hidden files or folders existed in the specific directory trying to be deleted using below command and remove them with rm -rf <name> command.

ls -la <foldername>

These hidden files or folders may contain file locks which prevents the files or /home folders from deletion.

Also, you can try adding a web jobs under an app service as detailed in this blog by @Niels Swimberghe.

You need to provide a required PowerShell or SSH script by adding the folder deletion code in it and upload in the web job creation part as shown below.

Once it has been created and triggered, the relevant script gets executed accordingly.

If nothing from the above supports, you can go with the FTP file server for deleting it. Get the FTPS credentials by visiting Deployment Center >> FTPS Credentials under an App Service as shown here.

Retrieve the username and password credentials and use any FTP client to connect to your App Service. Once connected, you can visit the specific folder and delete it.

Note: Restart your App service once again and try the operations if required.

本文标签: rmCan39t delete folder on Azure Persistent StorageStack Overflow