Search code examples
azure-devopsazure-pipelineswebdeploy

Getting ERROR_FILE_IN_USE while using Web Deploy in Azure App Service Task v3


Similar questions have been asked various times, but most answers are old and may only partially apply. This question is specific to using Web Deploy through Azure DevOps/Azure Pipelines using the "Azure App Service Deploy" task, version 3.*.

Failed to deploy web package to App Service.

Try to deploy app service again with Rename locked files option selected.

Error Code: ERROR_FILE_IN_USE

More Information: Web Deploy cannot modify the file 'VBCSCompiler.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.

There's two recommendations there:

  1. Select "Rename locked files" option
  2. Restart the application
  3. Use the AppOffline rule

Additionally, the documentation for the task reiterates recommendations 1 and 3 together.

For avoiding deployment failure with error code ERROR_FILE_IN_USE, in case of .NET apps targeting Web App on Windows, ensure that 'Rename locked files' and 'Take App Offline' are enabled. For zero downtime deployment use slot swap.

However, these recommendations are already in place. Deployment settings

All that's left is recommendation 2: restart the service. For many reasons, I rather not have to fall back to this.

Why are 1 and 3 not enough to complete the deployment successfully?


Solution

  • I spoke with a Microsoft support rep and was told that "Rename locked files" only works for DLLs.

    But I did find a solution that did work for me. In "Additional arguments", I added "-useChecksum". So the "Deploy Azure App Service" task now looks like this

    enter image description here

    I haven't had any problems since.