Link to home
Start Free TrialLog in
Avatar of Alessandro Scafaria
Alessandro ScafariaFlag for Italy

asked on

How do I automate maintenance in my IIS web app with Powershell?

Hi there,

I just wondering how to figure out with a solution that allows an application to signal to our load balancer that it is no longer part of a load balance pool...

I imagine to place a sort of empty "flag" file named "ExposeToLoadBalancer.flag" into the web application folder that will cause a particular URL within the application (that the loadbalancer monitors) to return a "200 OK" status code - and the load balancer will send  http requests to the application.

Instead, if the file does not exist, then the application will respond with "503 Under Maintenance", and this will cause the loadbalancer to no longer send new requests to the application.

This is the idea to automate the process.....but I'm not sure if it may be correct!

I'd like some help in order to create a script that can add the "ExposeToLoadBalancer.flag" to each application directory and one that will remove it.

Once a web application has been hidden from the loadbalancer, it can be stopped.
I assume to wait 30 seconds between "hiding" and stopping - just to allow any "in-flight" requests to complete.

Unluckly I'm not very confident with PS using IIS....could someone give me a hint?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alessandro Scafaria

ASKER

Hi Dan,

thank you so much for your reply!

I'm using ARR as load balancer for my Web Farm built with IIS 7.5.

I'll try to answer properly to your bottom questions in only one shot:

Unfortunately, releases of web applications are frequently. During release, I usually hide and stop the existing version of an application, then install the new version and then start and expose the new version. All the while maintaining the old version (in case I need to roll-back).

I try to achieve this through folder structures that have a version number in their path and through website names that also contain a version number.

In your opinion, how should I "force" to remember what are the actual active sites in the script? This is important when, for example, a release of a website that was not successful, and that the latest version of one of the applications is not actually the "live" version.

Usually my maintenance window requires also a reboot. Is it possible to automate it too?

Many thanks for your help!!
Here are a few articles on IIS and ARR:

Health Check:  http://blogs.iis.net/richma/archive/2010/12/14/application-request-routing-health-check-features.aspx

List of links:  http://www.iis.net/learn/web-hosting/scenario-build-a-web-farm-with-iis-servers

I understand your process, but I'm not sure I get the "how should I force" statement.  Let me restate your statement to see if I understand it:

1. script sets 1 or more ARR load balanced websites to "unhealthy"
2. script should know or have a list of active websites
3. script should reboot server

So if that is correct, you can have, in a text file, the paths to each website on the web server.  The script can loop thru this text file and do a predefined set of actions.

That much is straight forward, without knowing your structure and naming format, I can't say much more.

How does IIS get (re-)configured so that it knows what files to serve up upon request?

Dan
Thank you Dan,

I appreciate! Here is an ideal example of my folder structure:

 C:\APPS

-----getinto2Italy
---------getinto2Italy
--------------101.16.7.0296
--------------------getinto2Italy.Service

-----getinto2France
---------getinto2France
--------------101.90.46.0296
--------------------getinto2France.Service.Host	

-----getinto2Ireland
---------getinto2Ireland
--------------101.90.46.0249
--------------------getinto2Ireland.Web.Admin

Open in new window


You made my point with your statements!

I'm not use how to help you when you're saying: "How does IIS get (re-)configured so that it knows what files to serve up upon request?"....

Thanks in advance!
My question was, when you deploy a new version structure, what happens to the older versions?

-Do they stay in the "getinto2..." directory?
- Which of the directories in your example is the web root for the website?
- When someone goes to one of your websites, how do they know or how does IIS know, what URL to return?
- Are you using URL rewriting in ARR?

Have you experimented with web Deploy from MS?

Dan