Patrick Peters
Patrick Peters

Reputation: 9568

Azure App Service Deploy file in use

In my project we use Azure App Service Deploy task to deploy our webdeploy packages.

I noticed that sometimes I get a file in use error while deploying, even when the option 'Take app offline' has been set on.

What is the best way to fix this ?

This is the error:

2016-12-07T15:26:44.8411101Z ##[error]Failed to deploy website.

2016-12-07T15:26:44.8411101Z ##[error]Error Code: ERROR_FILE_IN_USE

2016-12-07T15:26:44.8421096Z More Information: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.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.

Upvotes: 3

Views: 1881

Answers (2)

Geert Doornbos
Geert Doornbos

Reputation: 51

You can now use the 'Azure App Service Manage' task to stop and start the app service to prevent files being in use.

enter image description here

Upvotes: 4

Patrick Peters
Patrick Peters

Reputation: 9568

I have a temporary fix as recommended in this page here

I have made a Azure CLI task using this command before the deploy:

azure webapp stop --resource-group XX --name YY

(where XX is the resource group name, YY the web app service)

Then performing the deploy using Azure Web Deploy Task

Then performing this Azure CLI task after the deploy:

azure webapp start --resource-group XX --name YY

And that works.

Upvotes: 2

Related Questions