0

I am trying to deploy multiple webjobs in a single release definition on VSTS.

My issue is that files contained in my webjobs can change (add/update/remove). By default, when a new version is deployed by using the task Azure app service deploy, no existing files are removed from the server. This result in deprecated files inside my webjob staying on my server and causing errors.

In order to fix my issue, I tried to enable the "Remove additional files at destination". But as I have to deploy each webjob in a separate task (Azure app service deploy supports only a single web package), each consecutive deployment deletes the files of the previously deployed webjob(s).

Any idea on how to solve this easily?

Currently my only guess is to Connect to web app through powershell and delete existing webjob with commandlet Remove-AzureWebsiteJob.
But my main concern with this is about deleting entire webjob(s) which I presume will also delete their logs and execution history...

GGirard
  • 1,145
  • 1
  • 13
  • 33
  • use a powershell task to run these functions https://stackoverflow.com/questions/43801618/remove-files-and-foldes-on-azure-before-a-new-deploy-from-vsts – vip32 Jul 05 '17 at 14:21

1 Answers1

1

There is a way you can do this that is not well documented, by using the wawsdeploy tool.

After you get the tool from Chocolatey:

  • Download your apps's publishing profile form the Portal.
  • Go to the folder where you have the files you want to deploy for a specific WebJob.
  • Run: wawsdeploy . c:\folderwithyourprofile\YourApp.PublishSettings /t D:\home\site\wwwroot\App_Data\jobs\continuous\YourJob /d

Here, the /d causes it to delete all unknown files within that one folder, so it won't touch your other WebJobs. You can try running it first without the /d to get comfortable with the tool and make sure it puts files in the right place before it starts deleting things.

Note that it's possible to do similar things with just the msdeploy command line, but it's requires an extremely complex set of parameters. See my post for some details on this.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thanks for the explanation, but my build/release definition is running on a VSTS hosted agent which does not allow me any administrative privileges (like using choco or installing new package on the agent). I will have a look to your article as if WAWSDeploy is only a wrapper around msdeploy, I should be able to achieve the same result if I can pass through the overhead – GGirard Apr 03 '17 at 16:39
  • Yes, you should be able to use msdeploy.exe directly, but the command line syntax is daunting. Doesn't VSTS have an msdeploy task you could just use? – David Ebbo Apr 03 '17 at 16:50
  • None of those available allow me to clean only the webjob folder on my azure web app – GGirard Apr 03 '17 at 17:58
  • Then they probably don't expose the full power of msdeploy. The ability to specify a physical target is a fairly advanced (and rarely used) msdeploy feature. I'm actually not entirely sure how to do this via straight msdeploy cmd line (but it must be possible). – David Ebbo Apr 03 '17 at 18:00
  • you can use this powershell https://stackoverflow.com/questions/43801618/remove-files-and-foldes-on-azure-before-a-new-deploy-from-vsts – vip32 Jul 05 '17 at 14:21