Publishing Azure Function with Web Deploy: Web deployment task failed

Problem Statement

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.

Solution

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,

Happy coding,

Tom Hundley
Elegant Software Solutions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s