Visual Studio Online / Azure Stop and Launch Web Applications Using Powershell

I use Visual Studio Online build tools to deploy web applications from a single solution. I sometimes ran into file locking issues.

Error: Web deployment cannot modify the file "Microsoft.CodeAnalysis.CSharp.dll" in the destination because it is blocked by an external process.

After some Googling, I think the “fix” is to stop the web applications before deploying to Azure and start backing it up afterwards. Sounds legal.

However, there seems to be no direct way to do this directly in VSO definitions. I created an Azure Powershell build task, but it wants to get the PS1 file from the repository. This does not seem to allow me to run Azure Powershell commands (e.g. Stop-AzureWebsite). My team created a working environment where we have "run.ps1", which simply executes the command that you pass as a parameter, but none of us are satisfied with this.

What are we missing? There should be an easier way to do this without checking the PS1 script in the source control.

+7
powershell azure vsts
source share
4 answers

I solved this by installing Azure App Services - Starting and stopping extensions from the Visual Studio Marketplace.
When installed, it will allow you to wrap the Deploy Website to Azure task in determining the release using the Azure AppServices Stop and Azure AppServices Start , effectively Azure AppServices Start blocking problems.

VSO Deployment Tasks

+3
source share

Make sure you use "/" in the "Web Deployment Package" path for folder separators instead of "\".

i.e. change

 $(System.DefaultWorkingDirectory)/My Project/drop/MyFolder/MyFile.zip 

for

 $(System.DefaultWorkingDirectory)\My Project\drop\MyFolder\MyFile.zip 

I noticed that this was the only difference between the one I received with the error and the others (the reboot step that I added did not help). As soon as I changed the way, I got his job.

Sounds crap, but my problem is fixed.

+2
source share

Did you use an assembly template that sets the correct msbuild parameters for your package? You can see how here . I would create an assembly using this template and see if you have the same problems. If so ping me on Twitter @DonovanBrown and I will see if I can understand what is happening.

+1
source share

Generally, it is good practice to have any scripts or commands necessary to deploy your software for verification in the source control as part of your assembly. Then they can be easily run with a small configuration at the assembly level. This ensures consistency and transparency.

Better yet, infer deployment scripts as part of the assembly and use a version control tool to manage the actual deployment.

Regardless of the configuration, as a mantra code, all Dev and Ops commands should live.

+1
source share

All Articles