Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Online / Azure stopping and starting web applications using Powershell

I'm using Visual Studio Online's build tools to deploy web applications from a single solution. I've occasionally been running into file locking issues.

Error: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.dll' on the destination because it is locked by an external process.

After some Googling, I believe the "fix" is to stop the web applications before deployment on Azure and start it back up after. Sounds legit.

However, there does not seem to be a straight forward way to do this directly on VSO's build definitions. I've created an "Azure Powershell" build task, but it wants a PS1 file from the repository. It doesn't seem to let me just run Azure Powershell commands (e.g. Stop-AzureWebsite) from here. My team has created a work-around where we have a "run.ps1" that just executes the command you pass as a parameter, but none of us are satisfied by that.

What are we missing? There has got to be an easier way to do this without having a PS1 script checked into source control.

like image 573
agartee Avatar asked Oct 29 '15 19:10

agartee


1 Answers

I solved this by installing Azure App Services - Start and Stop extension from Visual Studio Marketplace.
When installed, it will allow you to wrap the Deploy Website to Azure task in your Release definition with Azure AppServices Stop and Azure AppServices Start tasks, effectively eliminating the lock issues.

VSO Release tasks

like image 177
jansokoly Avatar answered Sep 22 '22 12:09

jansokoly