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.
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:
Add a stop task before deployment and a start task after the deployment.
This did the trick for me.
You can restart the Function App to release the lock. After that you should be able to deploy.