VSTS - Disable Application Before Deployment

I get this problem using continuous VSTS deployment for azure

Web Deploy cannot modify the file 'XXX' on the destination because it is locked by an external process 

the solution presented in this thread is to manually restart my application in azure, however it did not use VSTS, and the question was asked 2 years ago, this problem was fixed on the current VSTS, and if so, I would like to know because I have the same problem as the link mentioned above.

thanks

+2
source share
2 answers

You can use the "EnableMSDeployAppOffline" function to disable the application before deployment by following the instructions here: Web publishing updates for offline applications and usechecksum .

If this does not work, you can also create a PowerShell script as follows to stop the application, deploy and restart the application:

  param($websiteName, $packOutput) $website = Get-AzureWebsite -Name $websiteName # get the scm url to use with MSDeploy. By default this will be the second in the array $msdeployurl = $website.EnabledHostNames[1] $publishProperties = @{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceUrl'=$msdeployurl; 'DeployIisAppPath'=$website.Name; 'Username'=$website.PublishingUsername; 'Password'=$website.PublishingPassword} Write-Output "Stopping web app..." Stop-AzureWebsite -Name $websiteName Write-Output "Publishing web app..." $publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1" . $publishScript -publishProperties $publishProperties -packOutput $packOutput Write-Output "Starting web app..." Start-AzureWebsite -Name $websiteName 

PowerShell script from: Build and deploy an ASP.NET 5 application in Azure Web App .

+2
source

Essentially, you need to stop - expand - restart.

You have many opportunities to do this, but the easiest way:

1- Extension: Azure App Services - start and stop you can try the extension "Azure App Services - start and stop" https://marketplace.visualstudio.com/items?itemName=rbengtsson.appservices-start-stop

2- AzureCLI task From build or deployment windows, complete the Add am Azure CLI task (currently in Preview)

Add one before the deployment task with the Inline script:

 azure webapp stop --resource-group NAME_OF_YOUR_RESOURCE_GROUP --name WEBAPP_NAME 

Add another task after deployment with Inline script:

 azure webapp start --resource-group NAME_OF_YOUR_RESOURCE_GROUP --name WEBAPP_NAME 

I hope that help.

enter image description here

+2
source

Source: https://habr.com/ru/post/1240137/


All Articles