Solved

IIS7 - How to Save Configurations to a File for Applications, Application Pools and Virtual Directories

Posted on 2011-03-18
6
2,136 Views
Last Modified: 2012-05-11
My company just started using Windows 2008 R2 and IIS 7.  Previously we were using Windows 2003 and IIS 6.  We have a number of applications that use IIS application pools, virtual directories and applications (applications only in IIS 7).

With IIS 6, it was very simple to replicate a pre-configured Application Pool or Virtual Directory.  All we had to do was select the Application Pool or Virtual Directory, right click it, choose All Tasks, and select Save Configuration to a File.  Then we could create a replica of the Application Pool or Virtual Directory by choosing "New Application Pool from File" or "New Virtual Direcotry from File".  This was very convenient, and it allowed us to 1) save configurations before we made any changes - in case we needed to restore them, and 2) create new Application Pools and Virtual Directories from previously saved configruation files.

With IIS 7, we cannot find the Save Configuration to a File feature in the IIS Manager's interface.  We've done some research, and it appears that Microsoft removed this functionality from the GUI in IIS7.  It seems they've replaced it with a command line tool called appcmd.  We can't find good documentation on the appcmd command line utility, so we're a bit reluctant to use it without a better understanding.

So, here is what we need to do:

- Save a specific Application Pool's configuration to a file.  Then, create a new Application Pool using the saved configuration file's information, parameters, etc.  And, of course, the new Application Pool would need to have a different name.

- Save a specific Virtual Directory's configuration to a file.  Then, create a new Virtual Directory using the saved configuration file's information, parameters, etc.  We realize we would still need to change some of the configuration information after the new Virtual Directory was created from the saved configuration file.

- Save a specific IIS "Application's" configuration to a file.  Then, create a new IIS Application using the saved configuration file's information, parameters, etc.  Again, we realize some of the configuration information would have to be changed after the new IIS Application was created.

We're not looking to transfer anything from one IIS server to another.  We're working with the same IIS server, and we want to replicate Application Pools, Virtual Directories, and IIS Applications.  

In our case, a vendor's installation originally created the original Application Pools, Virtual Directories, and IIS Applications.  We're a partner with the vendor and we host their applications in several data centers throughout the U.S.  The vendor originally create their applications for single company on premise deployments.  And, they've asked us to transform their applications into mult-tenancy applications.  This was easy to do in IIS 6, but we're not quite sure how to handle it in IIS7.

So, to summarize, we need to learn how to save configurations for IIS Applications, Application Pools and Virtual Directories using IIS7.  And, we need to learn how to create new applications, pools and virtual directories from those saved configuration files.  And, all of this needs to be done on the same IIS 7 server.  I'm over simplifying our configuration here, but if we can establish how to do the above on one IIS server, we can perform the same operations on our other IIS servers.

And, of course, everything needs to be done yesterday and there is no time for us to be re-trained on IIS 7.  So, I'm hoping someone can provide me with the procedures or the command line syntax for saving configuration files for specific IIS applications, pools and virtual directories.  And, I'm hoping someone can educate us on how to create new IIS applications, pools and virtual directories from the saved configuration files.

If we have to use the appcmd command line utility, we will.  But we'd love it if someone could give us the precise syntax for performing the above for specific IIS applications, pools and virtual directories.

Sorry for the long-winded question.  And, thank you very much in advance for your help.
0
Comment
Question by:gcrickman
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:rjpilcher
ID: 35170242
0
 

Author Comment

by:gcrickman
ID: 35170398
Thanks for the web site references!  Sadly, we previously reviewed these websites and neither of them provide specific syntax for saving configuration information to a file for a specific IIS application, application pool or virtual directory.  Nor do they provide the syntax for creating new IS applications, application pools or virtual directories from saved configuration files.

We want to learn how to save configuration information to files for specific IS applications, application pools and virtual directories on the same IIS server.  And, we want to be able to use the saved configuration files to create new IS applications, application pools and virtual directories on the same IIS server.

Thanks again for your reply - it is very much appreciated!
0
 
LVL 3

Expert Comment

by:ServerGuyScott
ID: 35171788
If I understand your question correctly what you are looking to do can be accomplished with APPCMD (a command line tool for managing IIS).

APPCMD will allow you to:
    Create and configure sites, apps, application pools, and virtual directories
    Start and stop sites, and recycle application pools
    List running worker processes, and examine currently executing requests
    Search, manipulate, export, and import IIS and ASP.NET configuration

I use APPCMD all the time to update portions or all of a configuration file for the IIS server (applicationhost.config) or for a specific site (web.config)

You may want to check out this page:
http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:gcrickman
ID: 35172421
Thank you!  The web site you referenced (plus the information at mvolo.com/blogs) provides a great overivew of APPCMD.  I read all of the information on the web site plus the blogs.  I'm not trying to be lazy here (just careful), but I was wondering if you could provide me with the APPCMD syntax that would list and export to a file (probably xml) the configuration information for a specific Application, Application Pool and Virtual Directory?  And, the APPCMD syntax for creating new a new Application, Application Pool and Virtual Directory from the previously saved file that contains the configuration information.

From the web site you provided, I gather that I can run the following syntax:

%systemroot%\system32\inetsrv\APPCMD list apps "Default Web Site/MyApp" /config /xml > MyAppOutput.xml

My questions are:

1.  Does the above command provide all of the configuration information for the IIS Application?

2.  How can I use the APPCMD to add a new IIS Application using the saved configuration file (e.g. MyAppOutput.xml)?

3.  Assuming all of this is possible, could I use the same method for replicating Application Pools and Virtual Directories as well?

Thanks again for the web site reference.  I did read it all of its content.  Again, I'm not trying to be lazy, I just need some assurance (in the form of syntax) for creating new IIS Applications, Application Pools and Virtual Directories from saved configuration files.
0
 
LVL 3

Accepted Solution

by:
ServerGuyScott earned 500 total points
ID: 35172716
Well the good news is, if you just want the configurations you really don't need to export anything. They already exist on the file system in an XML format.

So let's say you want to "export" the onfiguration for the entire IIS server, all you would have to do is "Copy" the applicationhost.config (the root file of the IIS 7.0 configuration system. It includes definitions of all sites, applications, virtual directories and application pools, as well as global defaults for the web server settings (similar to machine.config and the root web.config for .NET Framework settings).

Then if you want a single site specific configuration you want the  - Web.config it is the main setting and configuration file for an ASP.NET web application. The file is an XML document that defines configuration information regarding the web application. The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings.

There is also an Administration.config - This configuration file stores the settings for IIS management. These settings include the list of management modules that are installed for the IIS Manager tool, as well as configuration settings that any management module uses.

Then Redirection.config - IIS 7 supports the management of several IIS servers from a single, centralized configuration file. This configuration file contains the settings that indicate the location where the centralized configuration files are stored.

To add a new site with APPCMD it would look like this:
Appcmd add sites /name:”gcrickman’s Site” /id:12 /bindings:http://mysite.com:80

You can create application pools with this:
appcmd add apppool /name: gcrickmanpool1

To export it would look like this
> %windir%\system32\inetsrv\AppCmd.exe LIST SITE "gcrickman’s Site" /config /XML > gcrickmas Sites.xml

> %windir%\system32\inetsrv\AppCmd.exe ADD SITE /IN < dgcrickmas Sites.xml

Before making any changes ALWAYS make a backup!
Open a command prompt as administrator and change to the %windir%\system32\inetsrv\ directory.
At the command prompt, type appcmd add backup "FirstBackup" and then press Enter.
0
 

Author Closing Comment

by:gcrickman
ID: 35172738
Outstanding feedback!  We used this posting and your original posting, and we're in great shape now.  Many thanks!
0

Featured Post

Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

Join & Write a Comment

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now