Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take web app offline while publishing?

Very often, when I hit Publish in VS13, I get the site to compile but when uploading I get the error saying that a file is busy.

Updating file (MyAzureSite\PrecompiledApp.config).
C:...\v12.0\Web\Microsoft.Web.Publishing.targets(4255,5):
Error ERROR_FILE_IN_USE: Web deployment task failed.
(The file 'PrecompiledApp.config' is in use.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)

When I follow the link provided, it's suggested that I should go for enabling the appOffline rule. "Sure!", I think to myself. But how?! I've googled it, only to get a bunch of hits on the file that's supposed to replace the site while publishing. However, I get no info on how to get rid of my little problem.

I went the easy way and downloaded a publishing profile from my Azure web site and now I'm using it (you know, ALT+B+H).

Right now I resolve the problem by going to the portal for Azure and manually take the site off-line. Then I can publish and after that I take the site on-line. Highly impractical and painfully tedious.

What is causing this and how do I kill it?

like image 314
Konrad Viltersten Avatar asked Dec 26 '13 23:12

Konrad Viltersten


People also ask

How to take a website offline IIS?

In a lot of scenarios, you'll want to take a web application offline while you make changes to related components, like databases or web services. Typically, in IIS and ASP.NET, you accomplish this by placing a file named App_offline. htm in the root folder of the IIS website or web application. The App_offline.

What is App_ offline?

The App Offline file ( app_offline. htm ) is used by the ASP.NET Core Module to shut down an app. If a file with the name app_offline. htm is detected in the root directory of an app, the ASP.NET Core Module attempts to gracefully shut down the app and stop processing incoming requests.

Where is the App_ offline htm?

Make sure that app_offline. htm is in the root of the virtual directory or website in IIS. Show activity on this post.


2 Answers

You actually configure it in the publishing profile (.pubxml). Just add the element to the PropertyGroup like this:

<PropertyGroup>   <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>   ... </PropertyGroup> 

More in this MSDN document

like image 161
AKhooli Avatar answered Sep 21 '22 02:09

AKhooli


The Azure App Service Deployment Task has a checkbox for this (from version 2.0 onwards), under Additional Deployment Options: Take App Offline. Check that and you should be good to go.

Take Application Offline: Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully.

Screenshot: enter image description here

like image 21
Andrej Kyselica Avatar answered Sep 24 '22 02:09

Andrej Kyselica