Different default identity for dynamically created app pools on Azure

by ingvar 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;
   serverManager.CommitChanges();
}

Tags:

About the author

Martin Ingvar Kofoed Jensen

Architect and Senior Developer at Composite on the open source project Composite C1 - C#/4.0, LINQ, Azure, Parallel and much more!

Follow me on Twitter

Read more about me here.

Read press and buzz about my work and me here.

Stack Overflow

Month List