Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web App deploy: Web Deploy cannot modify the file on the destination because it is locked by an external process

I am using the "Azure Web App Deployment" build step in VSTS to publish an ASP.NET Core API to an Azure Web App:

Azure Web App Deployment

Occasionally, this step breaks with the following error:

[error]Microsoft.Web.Deployment.DeploymentDetailedClientServerException: Web Deploy cannot modify the file 'MyProject.Api.exe' 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.

This GitHub issue raises the same issue, but there is no suggested solution using the Azure Web App Deployment build step.

like image 552
Dave New Avatar asked Jun 20 '16 09:06

Dave New


2 Answers

As per a separate thread in the Microsoft Github repo here, there's a hacky workaround where if you add the following key to the Azure Appsettings, it can help resolve the locked file deployment error:

MSDEPLOY_RENAME_LOCKED_FILES = 1 

I'm not sure how long this appsetting hack will be supported, but it did help solve the issue for me personally.

enter image description here

like image 178
Ben Barreth Avatar answered Oct 25 '22 10:10

Ben Barreth


I was struggling with the same locking issue.
There are now a new Tasks (in Preview) that you can add for starting and stopping the App Service:

enter image description here

Add a stop task before deployment and a start task after the deployment.

enter image description here

This did the trick for me.

like image 36
Magnus Johansson Avatar answered Oct 25 '22 10:10

Magnus Johansson