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?
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.