How to clear the kudu files like wwwroot folder etc

Ravinder Reddy 40 Reputation points
2025-03-16T17:17:40.8733333+00:00

I'm trying to clear the files in kudu portal before each deployment

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,646 questions
0 comments No comments
{count} votes

Accepted answer
  1. Damilola Onadeinde 475 Reputation points
    2025-03-17T17:49:31.1033333+00:00

    in addition to @Divyesh Govaerdhanan 's answer,

    if you are deploying this from a pipeline, you can have this option checked if it is unchecked in azure pipeline "app service deploy" task
    Remove additional files at destination

    User's image

    You can use this task in yml pipeline. kindly reference for more information https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-rm-web-app-deployment-v4?view=azure-pipelines

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'your-subscription'
        appType: 'webApp'
        WebAppName: 'your-app-name'
        packageForLinux: '$(System.DefaultWorkingDirectory)/**/*.zip'
        RemoveAdditionalFilesFlag: true    # This is the key setting
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Divyesh Govaerdhanan 2,955 Reputation points
    2025-03-16T23:41:35.3666667+00:00

    Hello,

    Welcome to Microsoft Q&A, thank you for asking your question.

    -If you wish to manually ‘delete’ all the files from the intended folder, you may simply use the UX “Delete” button on the App Service Kudu console. (screenshots below)

    -Or as you would typically delete folder content on-prem (doc) via CMD or PowerShell, clear the content of the intended older (including subfolder, subfiles, except the Folder itself).

    Important: The delete operation would be irreversible once it is performed.

    Copy

    CMD/Bash  
    del / PATH_TO_FOLDER\*.*  
    for /d %i in (PATH_TO_FOLDER\*.*) do @rmdir /s "%i"  
    

    -> /S : Delete all files and subfolders in addition to the folder itself.

    -> /Q : Quiet - do not display Y/N confirmation

    Example: del /q Test* for /d %x in (Test*) do @rd /s /q "%x"

    -Reference: discussion

    160019-image.png ====via cmdlet==== 160078-image.png

    Please Upvote and Accept the answer if it helps!!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.