I’ve created an Azure Function and I’m using Web Deploy and a VS publish profile for quick test deployments before I build out my full release pipelines. When I publish the function more than once, I get this error:
Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Web deployment task failed. (Web Deploy cannot modify the file 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. Publish failed to deploy.
Open the Azure Portal and navigate to your Azure Function. Go to Application Settings and add this setting
MSDEPLOY_RENAME_LOCKED_FILES with a value of 1.
This will allow you to overwrite files in your directory.
I hope this helps someone,
Elegant Software Solutions