As I was deciding to build this, I was torn on where to begin. Should I build the front-end? Maybe I should model out the data entities, and build the API? After reading Clean Code by Uncle Bob, I quickly realized that my days of building a solution by starting at the database are over. I might feel more comfortable in the 3rd normal form, and be able to query anything when the data normalized, but that is not where my application will start.

Furthermore, clean architecture shows that items like the database are “accessory” items. I’ll eventually be making use of Entity Framework Core, but by using a code-first approach, I won’t have to worry myself much with building the database and tables ahead of time. I may have to build tables and views for the “Query” side of my CQRS design, but that will come later. The first thing I should build is the environment where my application will run.

My initial plan for my app

This application will run in Azure, so the first thing I did was create a resource group (using PowerShell and Azure CLI):

az login
az group create --location eastus --name LeagueTrackr_DEV --subscription SUBSCRIPTION_GUID

The az login command will pop open a web browser and look ask you to sign in to your Azure account. When that is successful, you can close the browser window, your terminal/PowerShell will then be authenticated. The next command creates a resource group. In Azure, all resources need a resource group and a subscription. I am going to assume you have a subscription already, that is usually set up when you create your Azure account.

az appservice plan create --name LeagueTrackrAppPlan_DEV --resource-group LeagueTrackr_DEV --is-linux --location eastus --sku B1 --subscription SUBSCRIPTION_GUID

This command creates what is called an App Service Plan. An App Service Plan determines what kind of “server” will be used to run my code. I put the server in quotes because I am making use of Azure’s Platform as a Service (PAAS) offering. I am not creating a VM with Linux or Windows, even though there will be one somewhere running my code. I am also telling my “server” to be on the basic 1 tier and be a Linux server. I chose the basic 1 tier because it is the cheapest just above the free tier. I would have preferred to use the free tier, but you cannot have two free app plans in one resource group.

az webapp create --name LeagueTrackr_DEV --plan LeagueTrackrAppPlan_DEV --resource-group League-Trackr_DEV --runtime "node|LTS"

Now I will do both of these steps again to create my API. Both the API and Web App could run in the same App Service plan, but in the event that I ever need to scale one and not affect the other, it would be difficult. For that purpose, I am going to split them out now.

Next, I will create the Azure SQL Server and the Azure SQL Database for my project:

az sql server create --admin-password PASSWORD --admin-user ADMINUSER --name leaguetrackrsql-dev --resource-group League-Trackr_DEV --location eastus --subscription SUBSCRIPTION_GUID
az sql db create --name LeagueTrackrDB_DEV --resource-group --server leaguetrackrsql-dev --edition Basic --subscription SUBSCRIPTION_GUID

Once this is complete, a dev environment will exist. However, the problem with this is that I don’t need to keep a dev environment around forever. If I am not actively developing, I’ll want to delete this environment to save me some money. I do want to be able to recreate this environment quickly if needed. I also want to be able to script any changes and push those to production when it is created. To do this, I’ll make use of Azure Resource Manager (ARM) templates and deploy them using Azure DevOps. I’ll look at this in my next post.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.