Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 218
Dan Friedman Avatar asked Sep 25 '18 17:09

Dan Friedman


People also ask

How do you deploy a Web service on Azure App Service?

To deploy to any Azure App service (Web app for Windows, Linux, container, Function app or web jobs), use the Azure App Service Deploy task. This task is automatically added to the release pipeline when you select one of the prebuilt deployment templates for Azure App Service deployment.


2 Answers

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.

like image 167
Dan Friedman Avatar answered Sep 28 '22 16:09

Dan Friedman


There is an issue tracked here : Azure App Service Deploy fails for .net core 2.0 with ERROR_FILE_IN_USE and based on vincentdass's comment "PR #8457 for consuming new version of MSDeploy as per Web Deploy team recommendation." There will be an upgrade for msdeploy in future version.

However you can just checking Publish Using Web Deploy and Rename Locked Files, then creating a new deployment. Redeploy won't work because it won't pick up your changes to the release definition.

Reference below thread, you can check the discussion about this issue and troubleshoot accordingly.

like image 40
Andy Li-MSFT Avatar answered Sep 28 '22 16:09

Andy Li-MSFT