Fluent Installation

A friend of mine Nick Hammond has recently embarked on an interesting open source project to provide a fluent interface to setup a web server.  What is clever about the project is that it makes use of cmdlets meaning that it is easy to use in Powershell. Allowing you to plug into your deployment pipeline.

Far too often Dev, Test and Live environments differ wildly.  They all have their little quirks and nuances.  Comments like “Oh if you use test environment B remember that the site is on drive D not drive C” are far too common.

This project attempts to solve that problem by moving the task of setting up an environment from a manual to an automated repeatable one.

Here is a snippet of some sample code to configure a web site using the fluent API:

context
    .ConfigureWebServer()
    .CreateWebsite(site =>
        {
            site.Named(parameters.SiteName);
            site.OnPhysicalPath(@"C:\");
            site.UseApplicationPool(parameters.SiteName);

            site.AddBinding(binding =>
            {
                binding.UseProtocol("https");
                binding.OnPort(80);
                binding.UseHostName("local.site.com");
                binding.UseCertificateWithThumbprint("8e6e3cc19bf5abfe01c7ee12ea23f20f4a1d513c");
            });

            site.AddApplication(application =>
            {
                application.UseAlias("funkyapi");
                application.OnPhysicalPath(@".\api");
            });

            site.AddVirtualDirectory(virtualDirectory =>
            {
                virtualDirectory.UseAlias("assets");
                virtualDirectory.OnPhysicalPath(@".\Assets");
            });
        })
    .Commit();

The syntax is clear and readable. The hallmark of a good syntax/API is one where you know what it is doing just from reading the code.  You don’t need to dive into the implementation.

Under the covers the fluent API makes use of the Microsoft.Web.Administration assembly and in particular the ServerManager class.  In typical Microsoft fashion the ServerManager class wields a lot of power but out of the box it is hard to use and test (please start using interfaces Microsoft!!).  With Nick’s fluent installation project all of that changes!

I have already started to get involved in this project as I think it could grow into a very useful tool for automating the deployment/setup of websites. Why not check out the source code on github and get involved.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s