Created
August 5, 2015 23:28
-
-
Save DominicFinn/2f668ebcf67ae67be1b3 to your computer and use it in GitHub Desktop.
IIS administration with F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "C:\\git\\bitbucket\\iis-admin\\packages\\Microsoft.Web.Administration.7.0.0.0\\lib\\net20\\Microsoft.Web.Administration.dll" | |
open System | |
open Microsoft.Web.Administration | |
let siteName = "doms-wicked-site" | |
let name(siteType: string) = | |
String.Format("{0}_{1}", siteName, siteType) | |
let serverManager = new ServerManager() | |
let createSite(siteName: string) = | |
serverManager.Sites.Add(siteName, String.Format(@"C:\Sites\{0}", siteName), 80) | |
let applicationPool(poolName: string) = | |
let livePool:ApplicationPool = serverManager.ApplicationPools.Add(poolName) | |
livePool.Enable32BitAppOnWin64 <- true; | |
livePool.ManagedRuntimeVersion <- "v4.0"; | |
livePool | |
let site(siteName: string, poolName: string) = | |
let liveSite:Site = createSite(siteName) | |
liveSite.ServerAutoStart <- true | |
liveSite.ApplicationDefaults.ApplicationPoolName <- poolName | |
liveSite.TraceFailedRequestsLogging.Enabled <- true; | |
liveSite.TraceFailedRequestsLogging.Directory <- String.Format(@"C:\IISLogs\{0}", siteName) | |
let liveName = name("live") | |
let livePool = applicationPool(liveName) | |
let liveSite = site(liveName, livePool.Name) | |
let accName = name("acc") | |
let accPool = applicationPool(accName) | |
site(accName, accPool.Name) |> ignore | |
serverManager.CommitChanges() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment