35

I had a network failure while publishing (using visual studio webdeploy ) my webapp to azure. Later i tried again, Then i got the below error message.

Error 5 Web deployment task failed. (Web Deploy cannot modify the file 'NewRelic.Agent.Core.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.) 0 0 ABCD.ABCD.ABCD.ABCD

So i restarted my webapp several times, but same exception. then i tried with FTP. That was also a failure. After few minutes i tried again with visual studio web deploy, then publishing succeeded. But now i am getting a 503 error- site under construction. Any idea?

Note: I tried app offline also. No hope

Manu Mohan
  • 1,694
  • 2
  • 20
  • 31
  • well the error is telling you what the problem is.. perhaps the dll is locked on the remote server.. how are you consuming the dll perhaps there is an issue in your code in regards to how you are creating an instance of the dll and releasing the resources.. can't really tell without seeing what your existing code looks like in my opinion – MethodMan Oct 09 '15 at 18:50
  • iam using newrelic for webapp analytics. There is no issue with my code. It was working till today morning. But after deployment failure( due to network issue), i am unable to successfully deploy it once again – Manu Mohan Oct 09 '15 at 18:58
  • you can't assume that it's not working however if it just started..then I would contact the ISP and ask if your process in regards to IIS or what ever type of webserver they use can be restarted.. also is there a way that you can attach to the remote process..? – MethodMan Oct 09 '15 at 19:00
  • 3
    Thanks for your time :) . I resolved my issue. Solution was to remove offline html from root directory that is created because of the app offline rule i added to publish profile :D Sorry to bother you – Manu Mohan Oct 09 '15 at 19:31
  • 1
    I had the exact same problem. Your comment helped a lot, please publish it as an accepted answer. – Kostub Deshmukh Dec 08 '15 at 23:20
  • I posted it as an answer below – Manu Mohan Dec 22 '15 at 04:49

5 Answers5

67

I resolved my issue. Solution was to remove offline html (APP_OFFLINE.html) from root directory(on server) that is created because of the app offline rule i added to publish profile.

actual problem : <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline> in your publish profile that is actually used to take your app offline while deploying. After finishing deployment, MSDeploy tool should delete APP_OFFLINE.html automatically. But, somehow it did not happened in above case.

So what I suggest is, take a look at the root directory of your website and if there's a file called APP_OFFLINE.html, just remove that.

Manu Mohan
  • 1,694
  • 2
  • 20
  • 31
  • I had the same problem and was seraching the offline.html inside my local directory. But the file lay on the azure server... – kabaehr Apr 13 '16 at 10:38
  • 3
    @kabaehr yes, app_offline.html will be uploaded to your application directory in server – Manu Mohan Oct 13 '16 at 04:52
  • Had this same issue with an Azure Functions app. Deleted APP_OFFLINE.htm and then everything worked. (Azure Storage Explorer made finding and deleting the file a snap.) – System.Cats.Lol Nov 06 '18 at 20:00
  • How did a file like that appear? – President Camacho Mar 07 '19 at 15:39
  • @PresidentCamacho Your publish profile did that. You will have a section true in your publish profile that is actually used to take your app offline while deploying. After finishing deployment, MSDeploy tool should delete it automatically. But, somehow it did not happened in above case. – Manu Mohan Mar 08 '19 at 06:39
  • 1
    Thank you!.. It was hard time finding why it was happening regardless of deployment being successful! – Dhrumil Bhankhar Jul 30 '19 at 06:34
15

Culprit for this outage : app_offline.htm

This is a known bug with Azure Kudu service where it fails intermittently to delete app_offline.htm file from the server - https://github.com/projectkudu/kudu/issues/2949.

This file gets added to bring the site down temporarily and should be removed once the site is upgraded. But this is not happening consistently. As of Nov 2019, the bug is still open.

There is a simple work around for this :

  • Open your app service in Azure. On left hand panel, scroll and find Advanced Tools. Click Go. This will take you to Kudu service for your app service.
  • On the nav bar, click Tools > Zip push deploy.
  • There will be a file app_offline.htm in the list.
  • Click on delete button left to it and delete it. That's it! Your app should be up now.

Permanent Solution would be :

Tell Kudu not to create this file at all by adding key SCM_CREATE_APP_OFFLINE with value 0 in your appsettings.

Nameless
  • 1,026
  • 15
  • 28
1

FYI, this happened for me today, deployment automated through ADO CI/CD. It looks like the last deployment failed for ERR_FILE_IN_USE on the .exe for the web app itself, so it appears the rollback wasn't successful.

Joe
  • 1,295
  • 13
  • 16
0

This error can happen when publishing from Visual Studio using a publish profile and the publishing fails with an error.

The solution is to solve the publishing error.

In my case the error was connected with a locked file. Stopping the app service before publishing solved the issue.

Martin Staufcik
  • 8,295
  • 4
  • 44
  • 63
0

I figured out that, As I received Build Succeeded Email, and I go to browser and open the site. It showing "Site Under Construction". I wait 5 minutes, And than refresh. It loaded correctly. It looks like some time startup need more time as usual.

Shahid Malik
  • 163
  • 13