Visual Studio Team Services: Azure Web App Deployment failure - ERROR_FILE_IN_USE

Published Feb 12 2019 02:04 PM 387 Views
Occasional Contributor

First published on MSDN on May 22, 2016

Authored by Jeffrey Chilberto

 

Error Message.png

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: http://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:

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-335744%22%20slang%3D%22en-US%22%3EVisual%20Studio%20Team%20Services%3A%20Azure%20Web%20App%20Deployment%20failure%20-%20ERROR_FILE_IN_USE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335744%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20May%2022%2C%202016%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CI%3E%20Authored%20by%20Jeffrey%20Chilberto%20%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Error%20Message.png%22%20style%3D%22width%3A%20610px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F238537i94D9BD7D073C2535%2Fimage-dimensions%2F610x238%3Fv%3D1.0%22%20width%3D%22610%22%20height%3D%22238%22%20role%3D%22button%22%20title%3D%22Error%20Message.png%22%20alt%3D%22Error%20Message.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAs%20part%20of%20a%20VSTS%20Release%2C%20an%20Azure%20Deployment%20task%20was%20failing%20due%20to%20a%20locked%20library%20file%20preventing%20the%20task%20from%20modifying%20the%20file.%20%26nbsp%3BThe%20actual%20error%20message%20is%20shown%20below%3A%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%23%23%5Berror%5DWeb%20Deploy%20cannot%20modify%20the%20file%20'NewRelic.Profiler.dll'%20on%20the%20destination%20because%20it%20is%20locked%20by%20an%20external%20process.%20In%20order%20to%20allow%20the%20publish%20operation%20to%20succeed%2C%20you%20may%20need%20to%20either%20restart%20your%20application%20to%20release%20the%20lock%2C%20or%20use%20the%20AppOffline%20rule%20handler%20for%20.Net%20applications%20on%20your%20next%20publish%20attempt.%20Learn%20more%20at%3A%20%3CA%20href%3D%22http%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D221672%23ERROR_FILE_IN_USE%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D221672%23ERROR_FILE_IN_USE%3C%2FA%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3EThe%20command%20performed%20by%20the%20task%20is%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fazure%2Fdn722468.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Publish-AzureWebsiteProject%20%3C%2FA%3E%20and%20the%20command%20does%20not%20support%20taking%20the%20website%20offline%20before%20deployment%20similar%20to%26nbsp%3Bmsbuild%20publishing.%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3EStopping%20the%20website%20before%20the%20deployment%20and%20starting%20after%20the%20deployment%20does%20release%20the%20lock.%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3EFor%20a%20classic%20web%20app%3A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fazure%2Fdn495288.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Start-AzureWebsite%20%3C%2FA%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fazure%2Fdn495185.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Stop-AzureWebsite%20%3C%2FA%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3EFor%20ARM%20web%20app%3A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmt619301.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Start-AzureRmWebApp%20%3C%2FA%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmt619293.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Stop-AzureRmWebApp%20%3C%2FA%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-335744%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20May%2022%2C%202016%20Authored%20by%20Jeffrey%20Chilberto%20--%20As%20part%20of%20a%20VSTS%20Release%2C%20an%20Azure%20Deployment%20task%20was%20failing%20due%20to%20a%20locked%20library%20file%20preventing%20the%20task%20from%20modifying%20the%20file.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Dec 07 2020 06:02 PM
Updated by: