Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created August 5, 2015 23:28
Show Gist options
  • Save DominicFinn/2f668ebcf67ae67be1b3 to your computer and use it in GitHub Desktop.
Save DominicFinn/2f668ebcf67ae67be1b3 to your computer and use it in GitHub Desktop.
IIS administration with F#
#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