Visual Studio Team Services: Azure Web App Deployment failure - ERROR_FILE_IN_USE
As part of a VSTS Release, an Azure Deployment task was failing due to a locked library file preventing the task from modifying the file. The actual error message is shown below:
##[error]Web Deploy cannot modify the file 'NewRelic.Profiler.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: https://go.microsoft.com/fwlink/?LinkId=221672\#ERROR\_FILE\_IN\_USE
The command performed by the task is Publish-AzureWebsiteProject and the command does not support taking the website offline before deployment similar to msbuild publishing.
Stopping the website before the deployment and starting after the deployment does release the lock.
For a classic web app:
For ARM web app:
Comments
- Anonymous
May 26, 2016
I’ve been browsing online more than 2 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me.In my opinion, if all webmasters and bloggers made good content as you did, the internet will be a lot more useful than ever before. - Anonymous
October 18, 2016
Seems like something that should be included in the Deploy Azure RM step provided my Microsoft. I'm excited for all of this new technology, like Azure to become enterprise ready. - Anonymous
December 01, 2016
Essentially you need to stop - deploy - restart .You have many options to do it but to more easy would be:1- Extention: 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-stop2- AzureCLI taskFrom the build or Deployment windows Add am Azure CLI task (currently in Preview)Add one before the Deployment task with Inline script: azure webapp stop --resource-group NAME_OF_YOUR_RESOURCE_GROUP --name WEBAPP_NAMEAdd another one after the Deployment task with Inline script: azure webapp start --resource-group NAME_OF_YOUR_RESOURCE_GROUP --name WEBAPP_NAMEI hope that help. - Anonymous
December 16, 2016
http://stackoverflow.com/questions/20792405/how-to-take-web-app-offline-while-publishing