Let's Build It: URL Shortener in .NET

Welcome to the "Let's Build It: URL Shortener in .NET" course on Dometrain! This course takes you on a journey through building a production-ready URL Shortener system from conception to production. This repository contains the source code for the course, which you can use to follow along.

Getting Started

The main branch contains the most up-to-date version of the code, reflecting the latest improvements, updates, and fixes. If you're following along with the course, the final version of the code for each section is available on its corresponding branch. Below is the link to each section. You can switch to any section branch to access the exact code snapshot for that course part.

Sections

Infrastructure Costs Recommendations

This course aims to build the foundations of a globally scalable application. For that, it uses expensive Azure technology and features unavailable on the free tiers. The cost will naturally increase as the course progresses and we add more resources. So, it's progressively more costly. Also, during the course, we demo how to build 3 environments, which will increase the costs.

If you want to run and deploy the code while minimising the costs, we have some recommendations for you:

Course Notes

Infrastructure as Code

Download Azure CLI

https://learn.microsoft.com/en-us/cli/azure/

Log in to Azure

az login

Create Resource Group

az group create --name dometrain-urlshortener-dev --location westeurope

Deploy Bicep

What if

az deployment group what-if --resource-group dometrain-urlshortener-dev --template-file infrastructure/main.bicep

Deploy

az deployment group create --resource-group dometrain-urlshortener-dev --template-file infrastructure/main.bicep

Create a User for GH Actions

az ad sp create-for-rbac --name "GitHub-Actions-SP" \
                         --role contributor \
                         --scopes /subscriptions/89518450-6f9c-4039-8834-c5bab3ad3e92 \
                         --sdk-auth

Apply to Custom Contributor Role

az ad sp create-for-rbac --name "GitHub-Actions-SP" --role 'infra_deploy' --scopes /subscriptions/89518450-6f9c-4039-8834-c5bab3ad3e92 --sdk-auth

https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep

Configure a federated identity credential on an app

https://learn.microsoft.com/en-gb/entra/workload-id/workload-identity-federation-create-trust?pivots=identity-wif-apps-methods-azp#configure-a-federated-identity-credential-on-an-app

Get Azure Publish Profile

az webapp deployment list-publishing-profiles --name api-piza2nvlxc5jg --resource-group dometrain-urlshortener-dev --xml

Get Static Web Apps Deployment Token

az staticwebapp secrets list --name web-app-piza2nvlxc5jg --query "properties.apiKey"

Utilities

GitHub Actions