Getting started with AppHarbor

Unless you've been sleeping under a rock, you would have noticed the new trend toward hosting web-apps on PaaS platforms like Heroku, AppEngine and - aka "The Cloud". These platforms allow you to deploy your apps to an environment that's somewhere between shared hosting and a VPS (virtual private server), but charged by usage rather than a regular monthly fee. However their killer feature is that they allow you to scale up nearly instantly. So if you app makes it onto the front page of reddit, instead of your VPS melting and going into the foetal position, you can "spin up" more instances to handle the load.

Up until now the only viable option for running ASP.NET apps on a PaaS platform was Microsoft's own Windows Azure. Although I have no doubt it is a powerful platform, the general consensus is that it can be quite complex and quite expensive. I'm sure Azure is great if you're building the next Facebook, but if you just want to deploy a simple web-app cheaply, it can seem like an overkill. Luckily, I've discovered AppHarbor.

AppHarbor's official strap-line is "Azure done right", but unofficially it's "Heroku for .NET", as it uses the same deployment method as Heroku, one which revolves around version control and continuous integration. It goes something like this; push code changes to your remote Git repository on AppHarbor, it runs any unit tests in your solution, and if those pass, it deploys your app. Simple. The best part of AppHarbor is the price - free! For now, your can create a single instance app with a small database for zero dollars. They are a young start-up and are not yet charging for more instances or larger databases (they will soon), but have said they intend to keep a free version available. Lets run through a step-by-step guide to deploying an existing app.

Deploying Your First App

  1. Go to and create an account.
  2. Once signed-in, go to "New Application" and create your app.
  3. The next page will give you the details for your Git repository that you'll need to push to for your app to be deployed. Your git repository URL should be https://{Username}{AppName}.git
  4. Now back on your local dev environment, I'll assume you have your existing app bound to an existing Git repository. If you're new to Git, AppHarbor's support docs have some useful links; Deploying your first application.
  5. Fire up Git Bash and execute the following:
    • git remote add appharbor http://{Username}@{AppName}.git
    • git push appharbor master
  6. Back to AppHarbor, refresh your apps main page - you should see the progress of your build.
  7. Assuming your build succeeds, your app should be available on the default URL: http://{AppName} Voilà, your app deployed within a few minutes, for free!

Creating a Database

  1. If your app needs a database (currently only MSSQL and MySQL supported), go to your apps main page, at the bottom there is a section for databases; click "Add Database"
  2. Choose the type of DB, the requested size, name, and create it.
  3. The next page will give you the connection string to your DB. You can use your DB client tools (e.g. MSSQL Management Studio) to connect to it and configure it as needed.

Tips & Tricks

Use a Custom Domain

  1. Go to{AppName}/hostname/new and enter in the hostname you'd like to use for your app. Take note of the IP address they give you.
  2. You can enter in multiple host names and set one of them as canonical, which means all requests to other hostnames will be redirected to the canonical hostname. So a common scenario is to set up two hostnames, * and (canonical), which means any request to that doesn't begin with www will be directed to the www URL.
  3. Next you need to change your DNS settings; add an A record(s) pointing to the IP address noted earlier.

Coding Work-Arounds

  1. Don't rely on your app being on port 80: Your instances do not run on port 80, a load-balancer takes requests and forwards them to the appropriate port on the server where your app is actually hosted. The load-balancer does however forward the original host header. So if you have any code that builds up absolute URLs, you need to keep this in mind. There is an article on AppHarbor's support site for their recommended workaround.
  2. On every build, the entire app folder is deleted and recreated, so you can't store any user uploaded content within your site (e.g. your App_Data folder). A favoured approach is to use Amazon S3 to store files; because AppHarbor is actually built on top of Amazon EC2 (US-East region), if you choose the US Standard region for your S3 storage, you won't pay transfer costs because they are in the same region.

Comments (5)

Anwar Ishak
Jono - very useful article. Been toying with the idea of continuous integration and "proper" deployment methods in the last couple of months. Do share the link to your app, once you've deployed.
Thursday, 09 June 2011 01:19
For generating public url, we also have this guide:
Thursday, 09 June 2011 15:31
Cheers jono - nice tutorial. I must sign up before they tighten their taps.
Tuesday, 14 June 2011 16:54
I have seen a nice post here for deployment of website on cloud using appharbor tutorial is very self explaining with pics it is easy step by step guide
Sunday, 13 July 2014 21:24
Add a Comment