13. juni 2012 20:40
If you are creating app pools dynamically on Windows Azure, be sure to specify the desired identity. The reason for doing this is that, if you deploy with osFamily="1" the identity will be NetworkService, if you deploy with osFamily="2" the identity of the app pool will be ApplicationPoolIdentity. The latter might not work for your setup!
The reason for this difference is that osFamily="1" will give you a Windows 2008 server SP2. Using osFamily="2" will give you a Windows 2008 R2 and the two versions of Windows behaves differently when creating website/application pools.
Here is the code for creating an application pool where the identity is not left to a default vaule:
using (ServerManager serverManager = new ServerManager())
ApplicationPool applicationPool = serverManager.ApplicationPools.Add("MyName");
applicationPool.AutoStart = true;
applicationPool.ManagedPipelineMode = ManagedPipelineMode.Integrated;
applicationPool.ManagedRuntimeVersion = "v4.0";
/* This line is very important! */
applicationPool.ProcessModel.IdentityType = ProcessModelIdentityType.ApplicationPoolIdentity;