I am setting up an automated deployment project for a Sitecore website using TeamCity and Octopus Deploy (v. 3.3.6)…
Before deploying my package to the App Service using a “Deploy an Azure Web App” step, I would like to delete one folder on that site (/site/wwwroot/App_Config/Include), but leave all other files and folders.
Is there a built-in mechanism in Octopus to do this? I have tried using a Powershell script, but that runs on the server, not on Azure. Is there a way to run a Powershell script on Azure while deploying?
Or can I use the “Run an Azure Powershell Script” to do file manipulations on an App Service website without having to authenticate (since Octopus is doing the authentication)?
Or are there any other/better solutions to solve this without having to save credentials on the Build Server?
I would prefer not to use FTP for this, if at all possible.
Thanks for getting in touch!
There is nothing built in to delete certain files/folders within your web app at deploy time unfortunately.
The only way I have found that you can do it is by calling the Kudu service running behind your web app (https://yoursitename.scm.azurewebsites/) using REST to delete a file/folder (using the endpoints documented here https://github.com/projectkudu/kudu/wiki/REST-API#vfs). The issue is with trying to do this is you have to authenticate the call with your credentials and I haven’t been able to automate that without manually entering your credentials.
Run an Azure Powershell Script doesn’t actually run on Azure itself, the script runs on your Octopus server but have your Azure credentials and Azure cmdlets loaded. There are no PowerShell cmdlets (that I can find) to delete files on a Web App though.
I’m sorry to have to say it, but FTP might be your best bet…
Thank you and best regards,