2
votes

I have a site running on Azure.

When I publish from Visual Studio, I get an error message saying a file is in use.

If I then stop the site, and then publish again, and then start, everything is fine.

However, I would like to not be required to log into Azure and do this every time an update is made to the site.

Is there a way to do this?

This is the error message: Severity Code Description Project File Line Suppression State Error Web deployment task failed. (Web Deploy cannot modify the file 'GGL.OrderEntry.Data.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.) GGL.OrderEntry 0

The DLL is a project in the solution.

1
What file is it? I suppose it's a data-file or something similar. In general Azure App Services ( i.e. IIS ) do not lock application files: aspx, dll, etc. If you have a data-file, consider to store it somewhere else (Blob storage?).Fabrizio Accatino
Interesting, I will check this out further to see exactly what is getting locked.Greg Gum
I edited the question to show the dll that is getting locked.Greg Gum

1 Answers

5
votes

One way is to publish an app_offline.htm file to the root of the site. This uses an IIS feature to stop the application pool if it sees a file like this, which should release the locks and serve this file instead.

Another way would be to use Deployment Slots. You can stop the "staging" slot and publish to that. Then do a slot swap to get it to production. This has the added benefit of less downtime for users.

Deployment slots do need a Standard plan though.