Jesse Houwing 04 Apr, 2016
I’ve created a new VSTS Build & Release task to help you interact with the (VFS) Virtual File System API (Part of KUDU API of your Azure Web App). Currently this task can only be used to delete specific files or directories from the web app during your build or release workflow. It will be updated in the near future to also be able to list files or to upload / download files through the VFS API
The reason i made this task was that i needed it at my current customer. We’re deploying our custom solution to a Sitecore website running on Azure web apps using MSDeploy. The deployment consists of 2 parts: an install of the out-of-the-box Sitecore installation and the deployment of our customisations. When deploying new versions we want to keep the Sitecore installation and MSDeploy will update most of our customisations. Some customisations however create artifacts that stay on the server and aren’t in control of the MSDeploy package that can cause errors on our web application. This new VSTS Build / Release task can help you delete these files. In the future this task will be updated with other functionality of the VFS API such as listing, uploading or downloading files.
The task is available in the VSTS Marketplace and is open source on github.
Let’s have a look how to use this task and how it works under the hood. 
Using the task
So how do we delete files using this task? (Note: if you want to delete all files within a web app before doing a MSDeploy it’s better to check the “Remove Additional Files at Destination” checkbox in the advanced group of the Azure Web deploy task. This task is made to delete specific files or folders Using the task is pretty simple. install the task from the marketplace, add it to your workflow and fill in the following fields:- Azure subscription (select your Azure RM connection)
- App Service Name (select the web app you want to delete files at)
- File URL (enter the file url within the wwwroot that you want to delete. use path ending on / for directories)
- Recursive delete (Default ON if you select a directory also delete all files and directories in this directory)
- Skip non existing path (If file or directory does not exist any more do not throw error but continue)
- Allow self signed certificates (only use this when you you run in an ASE and have your own certificates)
- Alternative kudu URL (When running in ASE and the SCM url is different fill in the exact url here)
