Lab 9: Using AppCmd
This article has been moved to its new home here: https://benperk.github.io/msdn/2016/2016-IISLAB-lab-9-using-appcmd.html
- Install and Configure CSharpGuitarBugs on an IIS server as described in Lab 1
- Review one of the first articles I wrote at Microsoft here
Lab - Taking/Recover a Backup
1. Open a command prompt as an Administrator, navigate to C:\windows\system32\inetsrv and enter the following command
2. Review the contents of the backup
3. 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.
4. Attempt to open IIS or a browser pointing to http://localhost and you should get some error messages
5. Restore the backup and correct the breaking change
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.
2. Access a few of the website on the IIS server so that the worker processes are initialized.
3. Execute: AppCmd wp /? to get the syntax for listing the active worker processes.
4. 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.
5. Execute: AppCmd Site /? to get the syntax for listing the sites on the web server.
6. 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.
7. 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
8. What information in the result of the previous command do you find useful?
9. Execute: AppCmd stop appPool “CSharpGuitarBugs” to stop the worker process and AppCmd start appPool “CSharpGuitarBugs” to start the application pool again.
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.
2. Disable Anonymous Authentication using AppCmd by executing the following command: (check out step 6 for a tip on how to get the command)
3. Refresh the Authentication feature in the IIS Management console and you will see it was indeed set to Disabled.
4. 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.
5. Set the enabled attribute to True
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.
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?
1. Access the View by Manufacturer page in the CSharpGuitarBugs website, and notice the ‘real-time’ change in the feature.
2. 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.
3. This is some good information…why is this valuable information and what is it useful for?