How to Deploy Ghost to Azure - That was too easy

I've been planning on setting up Ghost as a blogging platform for a while now. Today, I googled How to deploy ghost blogging platform on Azure and first link was this post from Scott Hanselman.

I headed over to the GitHub Azure WebApp repo for Ghost, clicked the single click deploy button, signed into azure with my credentials and in less than a minute I was done. I was so blown away I had to tweet about it.

But then I had a bunch of questions:

  • How is single click deploy-to-azure even possible?
  • How do I update Ghost if there is a new release?
  • I want to fork the ghost repo and make some customisations, How do I upgrade ghost if there is a new release
  • How do I upload images?
  • Where are the images stored?
  • What type of database does Ghost use? Is it sqllite3?
  • How can I set a custom domain to example.com from the Azure Cli (ARM)
  • How can I move from Free to Shared or Basic pricing Tier
  • How do configure ghost to upload my images to Azure Storage?
  • When I deploy to Kudo, can I do a git pull and download the files locally?
  • How do I back up my blog?
  • How do I add comments using Discuss to my blog?

All reasonable question, but it's got me really, really curious about Azure, because I though I knew a lot about azure but there is a whole new layer now that seems lighter, simpler, and more efficient.

Let's find some answers.

How is single click deploy to Azure even possible?

if you include an azuredeploy.json file in the root of your github repo, you can enable single click deploy for your application. For me, that's really interesting! All you need then is the button link. Just add the following to your README.md and your are done!

[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/)

Notice, that the url doesn't even tell you where the master repo is! even more magic, because Azure deploy can figure it out from the referral url! I really love this.

To find out more go back and read Scott's blog post. He's got all the details there, include a great Azure Friday episode on how Azure Deploy works and what you need to put into your azuredeploy.json file to do funky stuff like deploying sql server and scalable resources with a single click.

Next question:

How do I apply updates to my version of Ghost ?

If the upstream GitHub Ghost repo gets updated, what happens to my snapshot? Can I apply the updates to my Blog that's already deployed to Azure?

It's a no brainer too. Already built into azure. Just login to the Azure Portal, choose your GhostBlog from the list of resources, click on Settings, then Deployment sources and hit the Sync button. If there are any changes you'll see it in the status.

If I find a way of updating from the CLI, I'll let you know.

Next Question:

How do I upload images

Just add ![] to your markdown it will create a preview placeholder and you can then either drag and drop an image onto the placeholder, or click the placeholder and upload an image. Sweet! (Alternatively, press Cmd-Shift-I)

Where are the images stored?

You can use Kudo to browse your live deployment folder. Find your azurewebsites.net url (mine is colhountechblog.azurewebsites.net) and insert .scm between the web app name and the azurewebsites.net bit (so mine would be colhountechblog.scm.azurewebsites.net), login in and click Debug console > CMD and you get a remote terminal shell and a nice file explorer ui. Browse to D:\home\site\wwwroot\content\images and you will find your images.

How do configure ghost to upload my images to Azure Storage?

I'll get back to you on that.I've found a blog on how to do this, but let me TL;DR first.

What type of database does Ghost use? Is it sqllite3?

Yes, it's sqllite3. Probably won't do if my site gets really popular, but for now it's perfect. Apparently, Ghost supports several different dbs out of town box, and sqllite3 is the default. To change you would modify the database setting in config.json.

Again, I'll probably be modifying this as I may want a different database strategy. Feels like another post coming on.

When I deploy with Kudo, can I do a git pull and download the files locally?

No and Yes. This setup uses WebHook to configure GitHub as the repo source. You would need to setup Azure deployment source as a Git Local Repository instead of using GitHub as a remote Repository. I'm literally going to do this next. For more on this watch this space!

How do I add comments using Discuss to my blog?

  • Create a Discuss account
  • get a universal code snipped
  • replace the page.url and page.identifier with the following:
this.page.url = '{{url absolute="true"}}'  
this.page.identifier = 'ghost-{{id}}';  
  • using kudo, browse to your site\wwwroot\content\themes\casper folder and update post.hbs. Insert your snippet somewhere between {{#post}} and closing {{/post}}
  • navigate to the wwwroot folder and do a npm install --production

It's all here

In conclusion

So, how did I do? I learned a lot and it took me longer to write this post that to discover all this loveliness!

Until next time...