1
votes

From Visual Studio 2019 I publish my ASP.NET Core 2.1 WebAPI to Azure.

The publish fails with this error message.

Web deployment task failed. (Web Deploy cannot modify the file 'xxxx.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.)

  1. If I manual stop in the App Service in Azure and then publish, the error does not appear.
  2. Problem happens intermittently.
1

1 Answers

3
votes

As a common practice, you can a new task on Azure Devops pipeline to stop the WebApp and restart the WebApp when deployment is done.

If you don't have downtime You can configure the Azure Web App to have multiple slots. Slots allow you to safely deploy your app and test it before making it available to your customers.

Also check Blue-Green Deployment with AppService