Harp on Azure Web Apps

Published on Thursday, December 31, 2015

Recently I have been trying out different frameworks like Ghost running on Azure Web Apps. I was trying to get away from just the standard ASP.NET or PHP solutions, branching out to Node.js or static site generators (more to come on that).

Harp

Harp is a Node.js / npm web platform that uses common template formats like Jade and Markdown to make it easier to author pages. Rather than providing a user interface for authoring, the process flow includes editing local files for content and layout.

Harp seems to be both a Static Site Generator and a Node.js hosting platform. For the purposes of this post I will be going through how to run Harp as a hosting platform.

  1. Initialize Harp directory

     harp init my-harp-app
     cd my-harp-app
    
  2. Initialize your app as a Git repo

     git init
     git commit -am "initial commit"
    
  3. Create a new Azure Web App

  4. Enable Continuous Deployment with a Local Git Repository

  5. Copy the repository clone url and add it as a remote repository

     git remote add azure https://user@my-harp-app.scm.azurewebsites.net:443/my-harp-app.git
    

    Note: my-harp-app will be replaced by your site name.

  6. Add package.json and server.js

     {
      "name": "harpapp",
      "version": "0.0.0",
      "private": true,
      "dependencies": {
        "harp": "0.19.0"
      },
      "engines": {
        "node": "4.1.x",
        "npm": "3.5.1"
      }
     }
    
  7. Then, use Node Package Manager to install the dependencies:

     npm install
    
  8. Next, create server.js, which should contain the following:

     require('harp').server(__dirname, { port: process.env.PORT || 5000 })
    
  9. Create a iisnode.yaml file which should contain the following

     node_env: production
    
  10. Commit any changes to Git

     git commit -am "adding node files"
    
  11. Deploy your Harp app to Azure

     git push azure master
    

At this point your site should be running on Azure at http://my-harp-app.azurewebsites.net, but with the subdomain you specifed instead of my-harp-app.

This article shows you how to create and deploy your Harp application to Azure using the Azure Command Line Interface (azure-cli) tool.

Stay tuned for more articles on web platforms and static site generators like middleman, Jekyll, Hexo, and more.

Thanks for reading.