My first blog

12 Mar 2016

azure blog how to

Inspired by Scott Hanselman I decided to create my own blog.

As Scott explains in his posts YourWordsAreWasted and YourBlogIsTheEngineOfCommunity, blog is a great way to preserve your knowledge.

I started paying more attention to what other people I value are using as their blog platforms. Most notably Troy Hunt, Scott Hanselman, Phil Haack and Paul Stovell.

I wanted to have something simple that I will be able to host on Azure preferably on free tier. First I tried ghost as it was available in Azure Websites gallery. It was nice to use but I was concerned by the fact, that I would have to use ssl to be able to securely log in and write posts. My other concern was that all created content would be only in Azure and I would have to come with some backup strategy to be able to move my content somewhere else if needed. Also ghost is running on a different technolgy stack that I am used to so running it locally would be troublesome. More over migrating to newer versions of ghost seem to be difficult as well.

So I decided to use something else, that will be open source and based on .Net - this is when I discovered BlogEngine.NET. After couple of minutes I had it up and running on my localhost. I was sure that it will be easier to maintain and update thatn ghost but still I would have to use ssl and some backups to be sure that I don't loose my content (and external plugins). Other drawback was that it wasn't using Markdown - and after using ghost I realy started to like it.

Both BlogEngine.NET and ghost seemed to be overkill to what I wanted to have. I wanted sleek and simple blog as the onw Paul Stovell has (have you seen his nice and simple html?). Then I heard about jeckyll - it allows you to have Markdown based, source controlled blog post that are complied to pure html after you commit changes to your repository. I found this post about file based blog using markdown and aspnet mvc3. At first I decided that I will try to write something simmilar by myself - I started looking at some Markdown engines - MarkdownSharp and CommonMark.Net. After reeding this article about WebEssentials using CommonMark.NET I decided to use CommonMark.NET along with highlight.js - it allowed me to use GitHub flawored Markdown with language hints instead of indentation (like ```cs) and easily change between syntax coloring styles. The only drawback was that it didn't support line numbering (and I liked that feature since I'm using Confluence which allows that in its code makro).

But before I fent fully ahead and reinvent the weel I decided I will do some research on GitHub for the similar projects. This is how I found pretzel and Sandra.Snow. To my surprise I discovered that default Sandra.Snow theme (the theme used by author of the repo Phillip Haydon) is the same as Paul Stovell is using! I was on a right track. This blog engine would allow me to have all that I wanted and it was already written with Azure in mind.

Nice thing about Sandra.Snow is that it allows you to easily enhance your blog with Disqus, Google Analytics and AddThis

After I played around with Sandra.Snow I realized that I will not be able to use highlight.js with it - Sandra.Snow is using Nancy.ViewEngines.Markdown to parse markdown files - and it uses MarkdownSharp that doesn't support GitHub flavored syntax (and ```cs language hints). So at the moment I'm bound to using Prettify and indentation to have my code nicely highlighted.

Next step was to create my own blog theme. After looking what free responponsive html templates are available on HTML5 UP and Scoop I decided to use Stripped theme. For the code highlighting I searched for some nice prettify skin in default skin gallery but I wasn't satisfied and I finally settled with this monokai theme.

Update:
I changed the theme - this time I created it from scratch using Bootstrap - Scoop theme wasn't displaying nicely on mobile devices. I also added support for rawgit cdn. For code highlighting I used GitHub prettify theme from jmblog

After blog was ready I started thinking about hosting. To be able to use custom domain name in Azure you need to use at least Shared app service plan. Here is where Visual Studio Dev Essentials comes to a rescue with it's $25/month free Azure credits. So I bought my domain on Namecheap and configured continuous deployment using Git (Kudu came to be very handy where it comed to troubleshooting deployment script - more about how to access it here). As a final step I had only configure Namecheap DNS records to play nicely with Azure.

Note:
When configuring DNS entires remember that you shouldn't put CNAME record on your root domain

Note:
When you want to point Multiple Domain Names to one website read How to Avoid Search Engine Problems When Doing So

Note:
Basic differences between the A and CNAME records are explained here

It sure need more tweeks but at the moment I'm pretty satisfied with the result.

var minions = new []{"Bob", "Stuart", "Kevin"};
foreach(var minion in minions)
{
    Console.WriteLine(minion);
}

minion


Bunch of interesting links (for me to remember how it works internally)

https://github.com/projectkudu/kudu
https://github.com/projectkudu/kudu/wiki/Accessing-the-kudu-service
https://github.com/projectkudu/kudu/wiki/Deployment-hooks
https://github.com/projectkudu/kudu/wiki/Customizing-deployments
https://github.com/projectkudu/KuduScript/tree/master/lib/templates
http://stackoverflow.com/questions/18309941/what-does-it-mean-by-command-cd-d-dp0-in-windows
http://stackoverflow.com/questions/6679907/setlocal-and-enabledelayedexpansion-usage-question
https://github.com/Sandra/Sandra.Snow/wiki


Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.