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 Force.com - 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

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}@appharbor.com/{AppName}.git

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.

Back to AppHarbor, refresh your apps main page - you should see the progress of your build.

Assuming your build succeeds, your app should be available on the default URL: http://{AppName}.apphb.com/. Voilà, your app deployed within a few minutes, for free!

Creating a Database

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"

Choose the type of DB, the requested size, name, and create it.

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

Go to https://appharbor.com/application/{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.

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, *.appname.com and www.appname.com (canonical), which means any request to appname.com that doesn't begin with www will be directed to the www URL.

Next you need to change your DNS settings; add an A record(s) pointing to the IP address noted earlier.

Coding Work-Arounds

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.

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.

For generating public url, we also have this guide: http://support.appharbor.com/kb/getting-started/workaround-for-generating-absolute-urls-without-port-number

Thursday, 09 June 2011 15:31

Jono Ward

@Anwar - Thanks mate! About continuous integration, at work we use CruiseControl.net, works really well, makes deployments a lot easier and the dashboard gives you a nice overview of any glaring problems with your projects (e.g. build/compile errors, unit tests failing). About the link to the app - you're on it now! For now this is just my blog, but eventually I'll expand it into something bigger.

@friism - Thanks for that, your partner @troethom gave me that tip last night, I updated the post afterwards. Really great that you guys actually take the time to read and comment about what people are saying about your product.

Cheers jono - nice tutorial. I must sign up before they tighten their taps.

Tuesday, 14 June 2011 16:54

Harman

I have seen a nice post here for deployment of asp.net website on cloud using appharbor tutorial is very self explaining with pics it is easy step by step guidehttp://geeksprogrammings.blogspot.com/2014/07/deploy-asp.net-app-appharbor-cloud.html

Sunday, 13 July 2014 21:24

Add a Comment

Name

Email (optional, not published)

Website (optional)

Me

I'm Jono, a South African developer living in London. This blog is my collection of thoughts around .Net/jQuery development, tech startups and gadgets. Feel free to contact me on jonoward [ at ] gmail dot com