Some days ago I had the opportunity to do a spike on making a small application and deploy it in App Harbor. I had never used App Harbor before, but I had used Heroku, which is another “Platform as a Service” (PaaS). Heroku is very easy to get started with and it’s easy to deploy to (it’s using git), so I had some expectations before I started.
Surprise #1, Add-ins
I had quite low expectations on what storage alternative that would be available – “a SQL Server service, a key/value store and perhaps a queue” was what I thought. The first thing that surprised me was that App Harbor has as many add-ins as Heroku (I didn’t count though) and I could choose between SQL Server, Couch, Mongo, Redis and RavenDB – all free in the most basic setting (i.e. small storage, no backup, etc). I turns out that RavenDB was added to the add-in stack quite recently. Cool.
Surprise #2, Learning RavenDB is easy
I added the RavenDB add-in to my app with a click and on its configuration page I saw both a link to the Silverlight administration tool and a url to the database. For about a year ago, I wanted to play with RavenDB at home, so I installed it on my personal machine but I couldn’t make it work. That is my personal experience with RavenDB, even if many colleuages and people in the community have praised it.
I wanted to drive my learning with small tests and thus created an empty project in Visual Studio. First I had to add RavenDB (client) and NUnit to the project, using NuGet. Then I went back to AppHarbor and clicked the RavenDB admin link, installed Silverlight, and RavenDB then asked me if I wanted it to add some sample data to my database, since it was empty, which I did.
After that I could easily find a “getting started” page with how to insert data into RavenDB, copy/paste that code into a test, replace the URL and run the test. It didn’t work…
It turns out that the URL and API key was separated with a semi-colon, which took me 2-3 minutes to figure out. DocumentStore has a property APIKey, so I set the API key there instead of having it in the URL and ran the test again. The test did not crash and a document appeared in the RavenDB admin application – success.
Move code to controller
I now had some test code that worked on my local machine that talked to a RavenDB database instance on App Harbor. The next step was to create a new ASP.NET MVC 4 project, move my test code to a controller action (nothing fancy, adding a redirect at the end of the code I already had) and run the proect. I clicked on a link to my controller action and again saw in the RavenDB admin app that a new document had been created, which was what I had expected. Nice.
git init git add . git commit -m "Initial commit" git remote add appharbor [my repo url ] git push appharbor master
I then opened up my app’s admin page in App Harbor, followed the link to my app and it worked just as on my local machine, as I expected.
Finally, I wanted to add some form of query from the database. The simplest kind of query is a Count(), so on the index page I added some code to show that. Now, each time I clicked the link, the counter was incremented with one – I did no longer need to go to the RavenDB admin app to see if a new document had been created.
App Harbor was very easy to get started with. It has many add-ins, including RavenDB. I thought it was easy to start using the RavenDB add-in: I could test the API from my local machine and then move the working code to a web project. Deploying to App Harbor with git is also very easy.