public static void CreateApplicationPool(ApplicationPool applicationPool) { using (var manager = new ServerManager()) { Microsoft.Web.Administration.ApplicationPool newAppPool = manager.ApplicationPools.Add(applicationPool.Name); newAppPool.UpdateIisApplicationPoolFromServant(applicationPool); manager.CommitChanges(); } }
public static void UpdateApplicationPool(string originalPoolName, ApplicationPool applicationPool) { using (var manager = new ServerManager()) { var pool = manager.ApplicationPools.Single(x => x.Name == originalPoolName); var apps = manager.Sites.SelectMany(x => x.Applications); foreach (var app in apps.Where(x => x.ApplicationPoolName == pool.Name)) { app.ApplicationPoolName = applicationPool.Name; } pool = pool.UpdateIisApplicationPoolFromServant(applicationPool); manager.CommitChanges(); } }
private static Microsoft.Web.Administration.ApplicationPool UpdateIisApplicationPoolFromServant(this Microsoft.Web.Administration.ApplicationPool iisApplicationPool, ApplicationPool servantApplicationPool) { ManagedPipelineMode pipelineMode; Enum.TryParse(servantApplicationPool.PipelineMode, true, out pipelineMode); LoadBalancerCapabilities loadBalancerCapabilities; Enum.TryParse(servantApplicationPool.ServiceUnavailableResponseType, true, out loadBalancerCapabilities); iisApplicationPool.Name = servantApplicationPool.Name; iisApplicationPool.AutoStart = servantApplicationPool.AutoStart; iisApplicationPool.ManagedRuntimeVersion = servantApplicationPool.ClrVersion; iisApplicationPool.ManagedPipelineMode = pipelineMode; iisApplicationPool.Recycling.DisallowOverlappingRotation = servantApplicationPool.DisallowOverlappingRotation; iisApplicationPool.Recycling.DisallowRotationOnConfigChange = servantApplicationPool.DisallowRotationOnConfigChange; iisApplicationPool.Recycling.PeriodicRestart.Time = servantApplicationPool.RecycleInterval; iisApplicationPool.Recycling.PeriodicRestart.PrivateMemory = servantApplicationPool.RecyclePrivateMemoryLimit; iisApplicationPool.Recycling.PeriodicRestart.Memory = servantApplicationPool.RecycleVirtualMemoryLimit; iisApplicationPool.Recycling.PeriodicRestart.Requests = servantApplicationPool.RecycleRequestsLimit; iisApplicationPool.ProcessModel.IdleTimeout = servantApplicationPool.IdleTimeout; iisApplicationPool.ProcessModel.MaxProcesses = servantApplicationPool.MaximumWorkerProcesses; iisApplicationPool.ProcessModel.PingingEnabled = servantApplicationPool.PingingEnabled; iisApplicationPool.ProcessModel.PingResponseTime = servantApplicationPool.PingMaximumResponseTime; iisApplicationPool.Failure.LoadBalancerCapabilities = loadBalancerCapabilities; iisApplicationPool.Failure.RapidFailProtection = servantApplicationPool.RapidFailProtectionEnabled; iisApplicationPool.Failure.RapidFailProtectionInterval = servantApplicationPool.RapidFailProtectionInterval; iisApplicationPool.Failure.RapidFailProtectionMaxCrashes = servantApplicationPool.RapidFailProtectionMaxCrashes; // Husk at opdatere GetDefaultApplicationPool return(iisApplicationPool); }