benjamin perkins, (aka @csharpguitar)

Lab 9: Using AppCmd

Setup

Lab - Taking/Recover a Backup

  1. Open a command prompt as an Administrator, navigate to C:\windows\system32\inetsrv and enter the following command

Using AppCmd

Figure 1, Using AppCmd
  1. Review the contents of the backup

Using AppCmd

Figure 2, Using AppCmd
  1. Open the c:\windows\system32\inetsrv\config\applicationHost.config file and make a breaking change, like deleting a large portion of the file and saving it.

  2. Attempt to open IIS or a browser pointing to http : //localhost and you should get some error messages

  3. Restore the backup and correct the breaking change

Using AppCmd

Figure 3, Using AppCmd

Lab – Monitoring/Administering IIS

  1. Open a command prompt, navigate to c:\windows\system32\inetsrv and enter AppCmd /? – This provides a list of objects and syntax of the tool. Review them.

Using AppCmd

Figure 4, Using AppCmd
  1. Access a few of the website on the IIS server so that the worker processes are initialized.

  2. Execute: AppCmd wp /? to get the syntax for listing the active worker processes.

Using AppCmd

Figure 5, Using AppCmd
  1. Enter the command to list the active worker processes, notice that the PID is also provided. This piece of information is required to take a memory dump using, for example ProcDump.

Using AppCmd

Figure 6, Using AppCmd
  1. Execute: AppCmd Site /? to get the syntax for listing the sites on the web server.

Using AppCmd

Figure 7, Using AppCmd
  1. Enter the command to list the sites, notice that the bindings and ID are also listed. Did you know that when you have a multi-tenant environment and you want to look at the IIS log files for a specific website, the ID is the number which is at the end of the W3SVC* directory.

Using AppCmd

Figure 8, Using AppCmd

Using AppCmd

Figure 9, Using AppCmd
  1. Next, make a request to the View By Manufacturer link within the CSharpGuitarBugs web site, while the request is running execute the following command: AppCmd list request

Using AppCmd

Figure 10, Using AppCmd
  1. What information in the result of the previous command do you find useful?

  2. Execute: AppCmd stop appPool “CSharpGuitarBugs” to stop the worker process and AppCmd start appPool “CSharpGuitarBugs” to start the application pool again.

Using AppCmd

Figure 11, Using AppCmd

Using AppCmd

Figure 12, Using AppCmd

Using AppCmd

Figure 13, Using AppCmd

Lab – Making changes to the configuration

There are a lot of ways to make configuration to IIS, PowerShell, AppCmd, IIS Management Console, Configuration Editor, etc…, pick your tool and master it, there are better tools than other… Notepad is not a good idea…

  1. In the IIS Management console, click on the CSharpGuitarBugs website and open the Authentication feature.

Using AppCmd

Figure 14, Using AppCmd
  1. Disable Anonymous Authentication using AppCmd by executing the following command: (check out step 6 for a tip on how to get the command)

Using AppCmd

Figure 15, Using AppCmd
  1. Refresh the Authentication feature in the IIS Management console and you will see it was indeed set to Disabled.

Using AppCmd

Figure 16, Using AppCmd
  1. You can achieve the same using Configuration Manager… With the CSharpGuitarBugs website selected, click on the Configuration Editor feature and navigate to the system.webServer/security/authentication/anonymousAuthentication property.

  2. Set the enabled attribute to True

Using AppCmd

Figure 17, Using AppCmd
  1. Before you Apply the changes, click on the Generate Script link, notice that you get the C#, JavaScript, PowerShell (IIS 8+) and AppCmd statements for the change you just implemented.

Using AppCmd

Figure 18, Using AppCmd

Lab – IIS Management Console Worker Process Management

You can also see similar information from with the IIS Management Console by clicking on Worker Process feature.

Install

Figure 19, Install

This will provide a list of all active worker process. Also notice the CPU % and Memory allocation per worker process, this is valuable information for benchmarking, right, why?

Using AppCmd

Figure 20, Using AppCmd
  1. Access the View by Manufacturer page in the CSharpGuitarBugs website, and notice the ‘real-time’ change in the feature.

Using AppCmd

Figure 21, Using AppCmd
  1. It would be nice to see which requests are being executed that are consuming the 17% of CPU. Access the View by Manufacturer page again, then double-click on the CSharpGuitarBugs Application Pool Name.

Using AppCmd

Figure 22, Using AppCmd
  1. This is some good information…why is this valuable information and what is it useful for?