AppHarbor – Heroku for .NET?

I have been reading about this new startup that offers a service called AppHarbor. It seems very much as the same idea as Heroku for Ruby, but for .NET. The basic idea is that you deploy your code by pushing your code onto the server using Git, the server then builds, runs unit tests and deploys your application. Super simple!

When I first read about AppHarbor I got the impression that is was running ontop of Microsoft Azure, which turned out to be all wrong. AppHarbor is running in the Amazon Cloud on EC2 instances. When it comes to databases AppHarbor provides access to MySQL and MSSQL. Interestingly they recommend users to use MySQL:

“we expect to be able to offer MySQL on faster hardware and with more redundancy than SQL Server at the same price point. If you are planning to build an app on top of AppHarbor and have the option, we recommend you go with MySQL.”

Another interesting choice is that they have chosen Nginx as their proxy/load balancer.

Ok, let me show you how easy it is to create a simple ASP.NET MVC 3 application and deploy it on AppHarbour The first step is to go to appharbor.com and register an account. Once created you will be able to create your first app:

Give your application and press create. You have done all the configuring you need to do at AppHarbor.

Lets create a MVC 3 project with unit tests:


Make sure your project builds and that the tests passes. Also make sure you have Git installed, if not you can fetch it from here. Now open a shell and cd into the folder where you created your application.

First we need to configure git with your name, the email you used to register at AppHarbor and last the git postBuffer size:

PS C:\dev\appharbor\MyCoolApp> git config --global user.name SourceCodeBean
PS C:\dev\appharbor\MyCoolApp> git config --global user.email mail@sourcecodebean.com
PS C:\dev\appharbor\MyCoolApp> git config --global http.postBuffer 52428800

After this we initiate the git repository:

PS C:\dev\appharbor\MyCoolApp> git init
PS C:\dev\appharbor\MyCoolApp> git add .
PS C:\dev\appharbor\MyCoolApp> git commit -m "initial commit"

And when this is done we add AppHarbor as a remote repository:

PS C:\dev\appharbor\MyCoolApp> git remote add appharbor https://moberg@appharbor.com/mycoolapp-1.git

We are now set to push our code onto AppHarbor. To push it just type:

PS C:\dev\appharbor\MyCoolApp> git push appharbor master

We should now be able to see the project building:

Hopefully it built successfully. A problem I ran into was that I had ASP.NET MVC 3 RC installed and AppHarbor had the RTM version installed, this caused my first attempt to build my project to fail. After upgrading my local version and fixing the project I pushed a new version that built without problems.

We can now browse to the site (yay! that was way easier than setting up IIS manually):

Failing tests

Ok, lets change something in our application that will make a test fail:

Now we are going to be bad and not run our unit tests before commiting and pushing the code

PS C:\dev\appharbor\MyCoolApp> git commit -a -m "a failing test"
PS C:\dev\appharbor\MyCoolApp> git push appharbor master

.. and we are building again

Woot! The build has failed!

We can easily see that it is the test that verifies the text on the start page that has failed

Ok, lets fix it!

Commit and push it again. And wait for the build to complete.

Yay! Our new version built successfully!

Lets check it out:

Rolling back to a previous version

Being able to rollback an update is sometimes necessary and AppHarbor makes it ridiculously simple, all you need to do is to press the “Deploy” link next to an old version. Clicking it will build and deploy the selected version.

We can now see that it is the first version that is active

I love the idea behind AppHarbor, this is really how sites should be deployed! However, using AppHarbor also means giving up some control over your environment. It will be interesting to see how they handle, for example, upgrades between different versions of IIS, installation of service packs, etc. Two features i miss is the ability to run background jobs and a distributed cache to use, but hopefully it will be coming to AppHarbor. AppHarbor still a very young startup, and so far what I have seen is really impressive!

1 comment on “AppHarbor – Heroku for .NET?

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>