3

We have an Azure DevOps release pipeline using the deploy azure app service task to deploy an application.

We would like to run a task prior to this deploy task to delete all files in the bin folder of the app service.

We do not want to delete all files on the target, just the ones in the bind folder.

I can't see any obvious task that will enable me to do this. Tasks seem to run in the context of the deployment server rather than the app service and so don't enable access to the app service file system.

What's the best way to do it?

Rob West
  • 5,189
  • 1
  • 27
  • 42

1 Answers1

-1

If you are looking to avoid unwanted files then in the Azure App Service Deploy task there is an option "Remove additional files at destination" which while not explicitly deleting the bin folder content will ensure there is no residue from previous releases.

enter image description here

Simon
  • 1,613
  • 1
  • 12
  • 27
  • Unfortunately that's not a viable option as we need some files on the server but not in the artifact, we just want to remove extra files from the bin – Rob West Sep 27 '19 at 14:43
  • Same issue here. I need to delete files BEFORE I deploy, because I have Nuget Packages that delete files and add new ones with new names. When I update this Nuget Package I have to delete the old files. Otherwise I have two files and that conflicts with the app logic. And I can't use "Remove additional files", too, because there are media library files stored in the same location, too. These files will also be deleted. – Elmar Höfinghoff May 18 '21 at 08:38
  • @ElmarHöfinghoff are those media files not part of the package you are deploying so will get added back? If not then you should really store the media files elsewhere like blob storage or a CDN, if stored and served from somewhere other than your app service it will also reduce load on your app. – Simon May 18 '21 at 13:19
  • No, they are not, they are part of the CMS. Media Files are added by editors as part of the website content and they must not be deleted. – Elmar Höfinghoff May 19 '21 at 07:37
  • @ElmarHöfinghoff I know it doesn't solve your immediate deployment problem but you should really store that kind of content outside of where you deploy the web application code. You may find changing that might be simpler than trying to find a workaround for your deployment issue. Sorry I can't be of more help. – Simon May 19 '21 at 11:27
  • @ElmarHöfinghoff as an aside if you had to scale your website to multiple instances then the content only existing locally would cause problems I suspect? – Simon May 19 '21 at 11:31
  • This option is no longer available in versions > 1 of this task. – Aaron Hudon Oct 23 '22 at 06:51