Where to start?
I decided to use Mads Kristensen Miniblog.Core
Since I like the dude, and it’s pretty much the only .Net Core Blog engine out there. And that is my main development platform - .Net and Asp.net. So as a technical blogger, I would prefer to custom enhance my blog with features over time, eating my own dog food in the process.
This article assumes some knowledge of the Git code versioning system. Download and Documentation here
A code editor. Preferably Visual Studio 2017 or greater. Or a lightweight editor like Visual Studio Code.
Make sure the .Net Core SDK 2.1 is installed.
Get it here: https://www.microsoft.com/net/download/windows .Net Core will run on Linux and MacOS as well. Plenty of sources online if you want to get acquainted with .Net Core platform. I’m just trying to covering a quick and dirty blog deploy here.
If you’re using Visual Studio 2017, make sure it’s version 15.7.x or greater.
Also I will be using Microsoft’s Azure as a Cloud Host. You’ll hear MS a lot around me, since I’m a Micro “Softie” and take advantage of the Virtuous Circle, and I know that I can setup a poor man’s Continuous Deployment (CD) directly from my Git Hosting account to Azure. I use Bitbucket as my git source control host.
The 1st problem is that Mad’s blog code is in Github. So I found this nifty Github gist describing steps to configure my local git repo to “sync” from Mad’s Github repo directly to my Bitbucket repo “Fork” of his code.
The gist be here:
If you use Github for source control, then swap out any time I say Bitbucket with Github, more or less.
If you start to follow my blog, you may find that I tend to go along the road less traveled.
Creating the Azure App Services “Website”
Log into the Azure Portal here: https://portal.azure.com
If you’re a Microsoft .Net developer at a company then they should be providing you an MSDN account for free. Which includes a Credit of up to $150 per month to use on Azure services (depending on your MSDN level).
If your company does not provide you an MSDN account, then complain or quit your job immediately and go pretty much anywhere else. Worst case, you just pay to use Azure per your usage. Any web host of some quality, you’ll end up paying some money. At least $10 bucks to slap your domain name on it from my experience if using a “free” to start host.
Let's see how may steps we can do this in:
1. In Azure Dashboard click on “Create a resource.”
2. Click on Web and then Web App
Source - (slightly out of date already):
Quick Start Tutorial link (for a .Net Core App) https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-dotnet
3. Give your Web App a name and put it in a Resource Group by giving that a name (if you don’t already have one).
I went ahead and turned on Application Insights (can be really useful). Not sure if there is an added cost, but likely easy enough to turn off later on.
4. Clicked on “App Service Plan/Location” so that I can ensure that my instance will be “Production” grade and that it doesn’t cost me an arm and a leg.
5. Click on “Pricing tier” next. The Default is S1 and that’s what we want (well what I want) starting out.
They will throw in the ability to map a Real Domain Name (your website name) for “free.” Among other amenities, which are actually really nice once you learn more about them.
6. Press Apply then OK when you’re done with this.
7. Finally, going back to the left and click the big blue “Create” button.
Should take a few moment for Azure to process and “stand up” your new App Service instance!
7 steps, not too shabby.
Hooking up Bitbucket to Azure for basic Continuous Delivery
Once it came back up, I did get a purplish (I like it) notice about a code deployment Quickstart. Perfect refresher opportunity?
Nahh, turned out to be a waste of time for my scenario.
We want to start by setting “Deployment Credentials.”
Make sure your save this info in something like Keepass or Lastpass (more on Keepass in a future blog).
Then click on “Deployment Options,” “Choose Source,” then the Holy Grail appears. Aka Bitbucket.
Dropbox, hmmm? That could be fun, but a story for another time perhaps.
Now you should see an Option to allow Azure to Authorize Bitbucket. Once clicked (and logged in) it should create the necessary webhooks for you within your Bitbucket account. How fancy.
Choose the Git Repo we created earlier (i.e. the github sync to bitbucket) and then choose master branch.
When happy, Azure will notify you:
And if there was any doubt, I can go back into my git repo settings in Bitbucket and see the Azure webhook created for me.
Usually I would create my next feature in the git source control then commit it to my Bitbucket and watch it auto-deploy (if it builds). But what’s this? A new Azure feature! Joy!!
Let's click on this Deployment Center (Preview) then Sync and.......
I went to my new (temp) Azure URL, and I got a homepage whoooo! https://criszis.azurewebsites.net
But where does content go? Was a database or some sort of datastore auto-magically initialized on my behalf? So many questions, so little time. Can only march on...
Wheww! That was a bit of a trek. Let's Celebrate.