Provisioning the Azure Environment

paint hands

Before digging into how to build this small environment to host our site. We must first cover some of the terminologies that will be seen in the Azure Portal and this post.

  • Subscription: A folder-like construct to create a logical separation of Azure billing and management configuration. Think organizations or business units.
  • Resource Group: A folder-like construct to create a logical separation of Azure services. Think deployment environments; development, test, production.
  • Azure Service: A product offering in Azure that a consumer can utilize.
  • Resource Location: The data center the Azure service will be hosted at. See here for locations.
  • Azure VM: An Azure service that allows a user to provision a virtual machine in Azure's infrastructure.
  • Azure App Service: An Azure service that allows for the hosting of applications in a scalable manner.
  • Azure Storage: An Azure service used to store data. In all honesty, this service can do SO MUCH more than store data. However, for our use case, think of it as a remote hard drive that we are going to put the website on.
  • Static website: A website that contains fixed content. No databases, no interaction with any data service. Some content is in a folder out on a server that a URL points to. Typically these are HTML, JavaScript, and CSS files in the folder.
  • Storage Explorer: An Azure tool allowing you the owner to view and manage the files being stored in the Azure Storage service.

Constructing the Environment

Provisioning a Resource Group

The first thing first, a Resource Group to define the blog environment. This resource group will be the container that all of the Azure services of the blog will be located. Isolating the blog from any other Azure services from other projects. While I don't see there being too many Azure services in use to host this static blog, but you never know what this thing will turn into. Choose the correct subscription, name the Resource Group blog and select any of the United States regions and we have our blog environment. That was easy enough. Now, what is the best Azure Service to host this static site?

What Exactly Do I Need?

"Best" is quite subjective. Isn't it? What is best for me, will not be the best for an enterprise static site. It may not even satisfy the criteria of best for a small business. So what does "best" mean to me? How about this:

  1. Quick to setup
  2. Cost-efficient
  3. Low maintenance

At first, I didn't have a good answer to this question. So this required some learning. My initial thoughts on some of the available options were:

  • Azure VM
  • Azure App Service
  • Azure Storage
Azure VM

This option would do the job, no doubt. There would be some more learning extra learning here as well. I have used this service in my professional career, but come to think of it. I have never started from scratch. While getting a VM provisioned I do not think will take longer, it could cause issues with the first criteria Quick to setup. A VM does not sound like it comes close to Cost efficient for my purpose. Okay, a VM is off the list. On to the next option.

Azure App Service

Again, this would do the job. Now I know from my professional career how to get this setup. In a couple of minutes, the service can be provisioned, then using the Azure KUDU console or FTP files can be dropped in the website directory. App Services are by definition low maintenance as well. However, the only question that is not answered. Are they cost-effective? Well, yes they are compared to the maintenance cost of a VM. But, I'm also looking at this through a different lens than I normally would. This is a static site. Azure's product and development teams are smarter than this as the static site offering. There has to be something smaller and cheaper. After all, some of the hosting providers talked about in the previous post are just directories hosted on the internet with some routing of traffic to those directories.

Azure Storage

Here it is, this has to be the best option. I know this is this will satisfy all of the criteria. The only thing is... Can you use it to host a static site? Come to find that is a really easy question to answer, yes it does. From the Azure documentation:

Static website hosting is a feature that you have to enable on the storage account.

Well, that simplifies this whole thing. This is the option to choose for my purposes. Time to provision one in the blog Resource Group.

Provisioning Azure Storage

As with the Resource group, in the Azure portal, you select the desired service. In this case Azure Storage you must define what it is and its size. Click the Create button. Then within a minute, you have your space out in Azure's cloud infrastructure to store data. With the service provisioned, there was a quick configuration change that had to be made. Once on the overview tab of the storage account in the left navigation, there is a static website setting. After enabling the static website setting. BOOM! A directory to host this blog. I was amazed at how easy this was. While it's not sending a person to Mars, but thinking of what just happened with a handful of button clicks. It could have taken me a week (if not longer) to get that set up if it was on my hardware. This technology thing is more and more amazing each day. Now that I had a place to put a static website, now I have to put a copy out in this new directory.

First Deployment

This is probably one of the easiest deployments I have ever been a part of. No complications whatsoever, given this is completely isolated and all static. Once the command to generate the static files was completed. Viewing the Overview page of the Azure Storage service, there is a tool to manipulate the files in the account. From there it was copy and paste files to the storage account. Once everything was uploaded. I opened another tab and pasted it in the Azure Storage service URL. Everything was live. All things told, this entire process only took about 30 minutes.

What did come to mind as files were being copied to the Azure Storage account, how should this deployment work in the future? Given this overlaps with my profession, I am well aware of CI/CD. I view it as a must-have for every professional project. But, do I need it for this project? How often will I be building the site and deploying it? Does it matter? After thinking about it for a couple of minutes, I knew if it was a completely manual process. I would be less likely to want to do it. I am not the biggest fan of mindless repetitive work and building/deploying this blog would be just that. So to keep me interested in and moving this forward, what are some of the options. I guess it was time to start digging back in to figure that out.

Player 2 Has Entered The Game

After only a couple of minutes, I remembered coming across an article on GitHub pages. From what I remembered this was an offering that comes with all Github accounts that one could use to host a static website. Then I thought of GitHub actions, again another tool that is offered by GitHub to execute actions such as build and deployment. I am normally not a GitHub user, however, I would use it if this was the case. I have a preference for GitLab, specifically for the private repositories offered at the time with a free account. GitHub offered private repositories only if you were a paid subscriber. Performing a quick search to learn more about pages. I discovered that GitLab also has an offering called pages, even better they have a Hexo example while the example had not been touched for about a year. The content had to still be pretty relevant. Best of all the example already had a .gitlab-ci-.yml that would build and deploy to pages. It looks like it may be best to pivot away from Azure and experiment with what GitLab has to offer. If this experiment fails, I could always move the site back into Azure. Then solve the problem of CI/CD to Azure Storage.

In my next post, I will detail what I did to take this project to GitLab pages.