Azure Web App deploy: Web Deploy cannot modify the file on the destination because it is locked by an external process

As per a separate thread in the Microsoft Github repo here, there's a hacky workaround where if you add the following key to the Azure Appsettings, it can help resolve the locked file deployment error:

MSDEPLOY_RENAME_LOCKED_FILES = 1

I'm not sure how long this appsetting hack will be supported, but it did help solve the issue for me personally.

enter image description here


I was struggling with the same locking issue.
There are now a new Tasks (in Preview) that you can add for starting and stopping the App Service:

enter image description here

Add a stop task before deployment and a start task after the deployment.

enter image description here

This did the trick for me.


You can restart the Function App to release the lock. After that you should be able to deploy.

enter image description here