azurew website continuous deployment - Web Deploy cannot modify the file 'XXX' on the destination because it is locked by an external process
Asked Answered
V

4

14

I'm running into the following error when trying to deploy an azure website via TFS continuous deployment.

I'm using the TfvcContinousDeploymentTemplate.12.xaml build definition template.

Exception Message: Web Deploy cannot modify the file 'Antlr3.Runtime.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE. (type DeploymentDetailedException)

I've done what was suggested and added

<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>

to the publish profile, however it's not putting the app offline as i'm getting the same error.

Here is a view of my build definition where it's set to use the publish profile with the app offline setting.

enter image description here

Vigen answered 12/9, 2014 at 17:24 Comment(1)
Are you using NewRelic?Ory
C
12

You ran into a limitation of Azure and .NET

Recommended is restarting your application. This can be done by changing an environment variable which in turn forces iis to restart.

For example: In the azure dashboard:

Set COR_ENABLE_PROFILING = 0

then deploy and then again

 Set COR_ENABLE_PROFILING = 1

You can find a description of this problem here

Cycling answered 16/12, 2014 at 8:50 Comment(3)
The Azure portal for WebApps now has a Restart button on the bottom the dashboard.Piles
We set COR_ENABLE_PROFILING to 0 and then got this: Error Web deployment task failed. (Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.dll' on the destination because it is locked by an external process. Any idea where this is comming from? It just started after installing the NewRelic APM. I had to then manually stop the site to deploy.Towroy
It could be that NewRelic uses this profiling, does it reoccur when shutting down NewRelic and then doing this change? (As @Piles says there is now a restart button on the bottom of the dashboard, this is an easier approach then having the change the profiling setting)Cycling
E
5

I know this is an old topic. But i had this problem my selve and solved it in Azure.

Add MSDEPLOY_RENAME_LOCKED_FILES=1 to your settings in Azure.

Azure settings

Effluent answered 13/1, 2017 at 12:52 Comment(0)
A
0

If you want to automate stopping and starting the Azure App Service before and after the deployment, then if you are using VSTS, this task is now available out of the box (if you are using TFS, please find the tip with a market place task in one of the comments)

To leverage these tasks:

  1. In Release section of VSTS, add a Task to your Release Definition of type "Azure App Service Manage (PREVIEW) - Start, Stop, Restart or Slot swap for an Azure App Service"
  2. In the created task, select the action (for the first task, select "Stop App Service")
  3. Drag and drop this task before the deployment task and add a "Start App Service" task behind the deployment task
  4. In the task settings, you can also check, that this is applied only to a specific slot of the Azure App Service (e.g. "Stage")

After configuring those two additional tasks, it was working fine for me.

(... by the way, VSTS Build and CI now also supports ASP.NET CORE builds made with VS2017 by selecting Agent "HOST VS 2017")

Auden answered 22/3, 2017 at 9:43 Comment(0)
R
0

If there is any automated option to do the below 3 steps, that should work.

  1. Stop app service
  2. Deploy code
  3. Start app service
Runic answered 27/5, 2018 at 1:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.