VSTS – 在部署之前使应用程序脱机

我使用VSTS连续部署到azure时遇到了这个问题

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

这个线程中提供的解决方案是手动重新启动我的应用程序,但是他没有使用VSTS并且问题是2年前被问到的,这个问题是否已修复在当前的VSTS上,如果是这样,我想知道如何因为我’ m具有与上面引用的链接相同的问题。

谢谢

您可以使用“EnableMSDeployAppOffline”function在部署之前按照以下说明将应用程序设置为脱机 : Web发布应用程序离线和usechecksum的更新 。

如果它不起作用,您还可以创建PowerShell脚本,如下所示,以停止应用程序,部署然后重新启动应用程序:

  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脚本来自: 构建ASP.NET 5应用程序并将其部署到Azure Web App 。

基本上你需要停止 – 部署 – 重启。

你有很多选择,但更容易做到:

1-扩展: Azure应用服务 – 启动和停止您可以尝试扩展“Azure应用服务 – 启动和停止” https://marketplace.visualstudio.com/items?itemName=rbengtsson.appservices-start-stop

2- AzureCLI任务从构建或部署窗口添加Azure CLI任务(当前处于预览状态)

使用内联脚本在部署任务之前添加一个:

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

使用内联脚本在部署任务之后添加另一个:

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

我希望有所帮助。

在此处输入图像描述