How to use IIS app_offline.htm file with Azure - azure

I have a brilliantly designed app_offline.htm file that I'd like to display on my site periodically when I'm doing things like backing up the DB. On a server with a real file system, this wouldn't be a problem: I'd just copy app_offline.htm to the my app's root, and IIS will work its magic and redirect all requests to this file.
However, I'm using Azure, so there's no real file system and there's no easy way move files around from one location to another.
How I can I make app_offline.htm play nicely with Azure?

I figured I'd add this, I haven't seen it mentioned yet. You can actually do this via web publish from Visual Studio (or WebMatrix) as well, just put app_offline.htm in the root of your project - the same level as your main web.config. When done, just rename it and redeploy to go back online. 2 clicks - easy.
The manual option is to drop it into your /site/wwwroot via FTP.
A little personal secret, none of your site files will be accessible, style sheets etc. So put your includes into an azure blob container, and viola.

Actually there is a real file system, as each VM instance runs on Windows 2008 Server (SP2 or R2 SP1). To see this for yourself, enable Remote Desktop for your deployment and connect to a running instance.
Knowing this, you should be able to set up a mechanism to perform a file-copy of your app_offline.htm to your app root based on some type of administrative command. You'll just need to make sure each of your web role instances perform this action.

David has provided you with a good answer. However, you might be missing out on what Azure can do for you. You should be able to virtually eliminate down time with Azure by running multiple instances and using SQL Azure which is triple backed up for you. You can also backup SQL Azure using http://msdn.microsoft.com/en-us/library/ff951624.aspx

Related

Web App for Containers (Linux) version of app_offline.htm

Occasionally, there are times when a system needs to undergo maintenance for a short time. Standard Web Apps handle this by redirecting all traffic to an app_offline.htm if the file exists in the root directory (wwwroot). What is the equivalent for a Linux Web App for Containers instance?
I tried using Kudu's Bash terminal by echoing the minimum html contents into an app_offline.htm but it isn't working.
One thing I was looking into would be having a specific container image that is for maintenance, but that doesn't seem very elegant.
Eventually, I would like to be able to automate this via Azure DevOps.
Are you able to create an app setting with the name SCM_CREATE_APP_OFFLINE and a value of 1 to see if this allows the creation of a app_offline.htm file?

Web Deploy Set Parameter using external file

We have an Website project that's hosted in Azure, and we use Web.config transforms for setting environment variables. However, our current approach for building the system for different environments is to build the project multiple times (currently this is 3), which is inefficient.
We'd like to move to using Web Deploy, as this would then set us up nicely for using Release Manager.
Our issue is around using Web Deploy parameters instead of web.config transforms; we need to substitute multiple xml elements, rather than single values.
After much research, I found these 2 articles which detail almost exactly what I'm trying to do
http://blogs.iis.net/elliotth/web-deploy-xml-file-parameterization
http://www.iis.net/learn/publish/using-web-deploy/parameterization-improvements-in-web-deploy-v3
Essentially I'm trying to replicate Scenario 5, but using a separate Set Parameter file for the value.
Unfortunately, in the examples, referencing an external xml file only works if it is on the target machine. Some testing with a colleague confirmed this; works on local machine, but not on Azure.
Is there a way I can force Web Deploy to look in a particular location for the external configuration files?
As you've already noticed, Web Deploy is only able to read replacement values on the local machine or on a UNC share. It can't read that specific file over HTTP.
If you're deploying to an Azure Web App, then one thing you could try would be to use Kudu/FTP to manually upload that file one level above your wwwroot folder. Then you could specify the file location like so:
D:\home\site\prices.xml:://book[#name='book1']/price
Of course this implies that you'd have to pre-upload this file before publishing to your site, so it's not a perfect solution, but it should work for what you're trying to accomplish.

Force Azure Publish to create empty folder

I use Azure websites and my project must have an empty folder on the server. When I publish the project from the Solution Explorer (VS 2013), I don't get it created on the server.
For now, I keep an empty file there to force the creation but I was wondering if there is a proper way to make the publish process create it for me.
Assuming you are WebDeploy from VS to publish your site, I think the only way to force creating a folder is to have it on your client side. If you use kudu you can look at post deployment actions
I would suggest updating your code though to create the folder if it doesn't exist. That would make your code more robust and self contained rather than depending on a certain deployment mechanism to create the folder for you.

Hosting an ISAPI DLL and supporting files in Azure

I am trying to find out how to host an ISAPI DLL in Azure. In addition to the DLL, I'll need to deploy supporting files in subdirectories (javascript & css files). And two of these subdirectories can have their contents changed by requests handled by the DLL, so I need to ensure that the account executing the extension has write permission for these.
It would seem that the key to all of this is using a startup task to call appcmd to script all the IIS changes somehow, and I think I need to do the following:-
Deploy my ISAPI DLL and supporting files with my ASP.NET website
Create a startup task which will call a batch file utilizing appcmd.exe to do the following:-
Create a dedicated app pool with its managed pipeline mode set to Classic, and using a known user account
Create an IIS application pointing to the directory where my ISAPI dll resides
Ensure the application is configured to allow unknown ISAPI extensions
Alter the permissions of the required subdirectories so the user account associated with the app pool has write access
I've only just started exploring Azure, so my experience with it is very thin on the ground. Is what I'm hoping to achieve actually achievable? And if so, am I on the right track with regards to the steps required? They mimic what I need to do if I'm setting up this ISAPI DLL in the traditional IIS environment I'm used to dealing with, but please let me know if the rules are different with Azure.
Looks like a good sequence, however, the startup tasks actually run before IIS is completely configured. The 'OnStart' event in the RoleEntryPoint is called after IIS is set up, so it's probably easier to use the IIS application that Azure creates for you, and reconfigure it to include your ISAPI stuff.
Well the only thing bothering me here is that you're modifying data on the 'deployment drive' (E: for that matter). You shouldn't be doing this.
Instead, think of an other solution. You could create a LocalResource holding your javascript and CSS files. Then, when your role starts (Richard has a valid point about startup tasks), use ServerManager class to do the following:
Register the ISAPI dll
Add 2 virtual directories under the website created by Azure and point them to the LocalResource.
Modify the code of your ISAPI dll to modify JS/CSS files in the LocalResource
When developing in Web/WorkerRoles, you need to keep in mind that you should only manipulate files in a LocalResource.

Setting read / write / execute privilege on "cgi-bin" folder in Windows Azure webrole

We're talking about a simple webapp.
So I have a file called "modulev2.cgi" which is part of a trusted 3rd party online payment company. This file has to be put in a folder named "cgi-bin". For windows IIS environnement the file is renamed "modulev2.exe" and put in the same directory. This is what the documentation says.
Module is called as this :
FORM ACTION=../cgi-bin/modulev2.exe METHOD=post
with a bunch of parameters. It should not download when called of course but execute.
And indeed it does work in my dedicated server, provided the "cgi-bin" folder and the file in have "execute" setting level in IIS.
So to the point, would I be able to set the rights to execute to this file in Windows Azure ? If yes, how to script such a process ?
Any help greatly appreciated.
Thanks !
The best way to do this is to script it out locally against your IIS using appcmd.exe. You want to add your CGI handler programmatically. By default, IIS in Windows Azure is already running CGI/Fast-CGI, so you don't have to install it, it should be ready. I think you need to add it to the CGI restriction list and add your handler mappings.
http://technet.microsoft.com/en-us/library/cc732851(WS.10).aspx
Once you have a .cmd file that will correctly configure your local IIS settings, you can use that as the basis for a Startup task in Windows Azure to bootstrap the role.
http://channel9.msdn.com/Shows/Cloud+Cover/Cloud-Cover-Episode-31-Startup-Tasks-Elevated-Privileges-and-Classic-ASP
http://channel9.msdn.com/Shows/Cloud+Cover/Cloud-Cover-Episode-34-Advanced-Startup-Tasks-and-Video-Encoding

Resources