Tags

, , , , , , , , , , , , , , , , ,

As some of you may already know, there is a site that is called Appharbor. It is well known in the .NET community as a cloud platform for deployment of .NET web applications , or in simple words- getting your Visual Studio Web project to run online in the “www._____.com” meaning (for non-local users). When I first heard of it I though “Cool, I get to deploy my first web site for free”(Appharbour has free features, good enough to get a simple site working). Well, my idea of “deploying” a web site in AppHarbor is waaaay far from a real deployment, but it’s a fun way of showing off as a site developer and a good practice. So let me give you my “comple7e for n00bs” guide and experience on this matter.

Intro

You can skip this part if you are more practice oriented.
So, basically Appharbor can serve as a, lets say, global Visual studio local-host server. It uses cloud technology. That is- it makes things you usually do on your computer on its servers. Things like testing, building, database management, etc.After that is finished, your project is deployed in a sub-domain(i.e. a site under appharbour) and can be accessed from anywhere, just like a normal internet site (Appharbour’s official explanation) To do this, it has to have the code. There are many ways to get a code online, but I’ll explain the option that GitHub provides us. Github uses a custom command prompt, called Git Bash to send files to its online repository(folders for your project/solutions). Once you manage to get it to the GitHub repostories it is send to Appharbour, where their server does its magic tricks and you have your application- up and running non stop.

GitHub- a quick set-up guide

Github's mascot
To get your code to appharbour, you first need to get a service to send your code to them. I’ll use GitHub, since it’s one of the most popular ways of controlling/storing your codes online.
Firstly, you need to create your free or payed account on GitHub . After you have managed to log in, the real deal begins. Now, there are many user-friendly guides on Github about getting your first project online, but I’ll give you the needed minimum to get a project online. You can find more advanced features yourselves.
Next comes the GitHub instalation(get the download from GitHub’s setup guide). The instalation steps can be default, so just click Next and Install.After you download and install it, you need to set username, email and password caching- they are shown as prompt commands(execute them from Git Bash as admin) in the Set up GitHub guide that I posted few lines above. Now, you need to create a new repository(repo for short)- you can find the button for that at the top left side as a small book-like icon. You can think of repositories as “folders” meant for a single project. A name is the only important thing you need to set at this moment. After that you will see a set of instructions, describing how to do a test upload of a “README.txt” file. These instruction are again prompt commands, that are executed in the Git Bash. Skip the Global setup part(we already did this). After you have done the commands and click continue, you will see the README file online.

Connecting GitHub and Appharbor


So, now we have to make Appharbour “listen” to Gihub’s repostory, in which we will store our project. After we have registered and created a new application in Appharbour, here’s what to do:
– Open your application and click “Build URL”. Open notepad and click paste.
– Go to your project’s repository in GitHub and click the “Admin” Button. Go to Sevice Hooks, then Appharbour. Here you put in your slug and token from your Build URL. The slug is the part between the slashes after “applications” in the URL. The token is everything after “builds?authorization=”. Select “Active” and then click “Update Settings”. Now we are connected.

Getting your project up and running

Last few steps left. Now, we get our working solution and just copy-paste it to our newly created Github folder(usually found in C:/Users/<<your-username>>/). After which we open a Git Bash in that directory(right-click in folder => Git Bash). We use the following commands:
$ git add * – this command adds everything in the directory to a list for upload.
$ git commit -m ‘<<some-message>>’ – commits the files with some message. Always add a message when commiting.
$ git push origin master – sends the files to your online repository(this requires password)
Note: If you want to delete an item just delete it in the folder and do the same commands, but use git add * -A instead git add *.
Now, your application has been sent to Appharbour and is being build and testes. If it finishes successfully, your application is ready and you can see it by clicking “Go to your application”. If it shows a 403 error, that means your side doesn’t automatically redirect to the Home page. You can fix this by adding “/<<your-home-page-file>>.aspx” to the URL. That’s it, congratulations!

Advertisements