Skip to content

About

Azure Cloud Resume Challenge

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

60 Commits

Folders and files

Repository files navigation

Antonio's Cloud Resume

Welcome to my take on the Cloud Resume Challenge – a cloud-focused project designed to showcase cloud engineering skills using Microsoft Azure.

This project is a static resume website hosted on Microsoft Azure. It includes a visitor counter built with .NET and Azure Functions. The entire setup runs on Azure’s free tier, so the only cost is the custom domain, which is optional.

πŸ‘‰ View my resume here

Architecture Diagram

Table of Contents

- File Structure
- What I used
- Local Workspace Setup
- Local Frontend Setup
- Azure Portal Setup
- Local Backend Setup
- Deployment to Azure
- Unit Tests Setup
- CI/CD Setup

File Structure

πŸ“ azure-cloud-resume-project/
β”œβ”€β”€ πŸ“ frontend/
β”‚ β”œβ”€β”€ index.html
β”‚ β”œβ”€β”€ πŸ“ css/
β”‚ β”œβ”€β”€ πŸ“ js/
β”‚ β”‚ └── main.js
β”‚ └── πŸ“ img/
β”œβ”€β”€ πŸ“ backend/
β”‚ β”œβ”€β”€ πŸ“ api/
β”‚ β”‚ β”œβ”€β”€ πŸ“ Models
β”‚ β”‚ β”œβ”€β”€ πŸ“ Services
β”‚ β”‚ β”œβ”€β”€ VisitorCounter.cs
β”‚ β”‚ └── local.settings.json
β”‚ └── πŸ“ tests/
β”‚ └── VisitorCounterServiceTests.cs
└── πŸ“ .github/
└── πŸ“ workflows/
β”œβ”€β”€ azure-deploy-frontend.yml
└── azure-deploy-backend.yml

What I used

Version Control

Git GitHub

Git was used to track code changes, while GitHub hosts the repository and enables collaboration. Additionally, GitHub Actions was used for CI/CD implementation.

Code Editor

VS Code

Visual Studio Code served as the primary tool for writing, editing, debugging, and deploying the code.

Cloud Service

Azure

The project was deployed using Azure Pay-As-You-Go Subscription - using only free services (All Azure Free Services)

All Azure Resources Used

Frontend

HTML5 CSS3 JavaScript

Built the user interface using HTML, styled it with CSS, and added interactivity using JavaScript.

Backend

C#

Developed the backend logic using C# for handling server-side functionality.

Local Workspace Setup

To begin the project, we need to ensure everything is working as expected locally before moving forward with the Azure implementation.

  1. Download Visual Studio Code
  2. Download Git
  3. Create a new repository on GitHub
  4. Clone the GitHub repo on your local machine
    • Run git clone in terminal
  5. Open the folder in VS Code via terminal
    • Run code . in terminal

Local Frontend Setup

After setting up the local workspace, we can start working on the frontend part of the project.

  1. Create a /frontend folder in the root directory
  2. Install Live Server or Live Preview extensions in VS Code
    ritwickdey.LiveServer
    ms-vscode.live-server
  3. Initialize Frontend code
    Create your HTML/CSS files in the repo. You can start with a simple template and customize it.
  4. Enhance your website design
    SVG Repo (Free SVG Vectors and Icons)
    Typed.js (Typing Animations Library)

Azure Portal Setup

Before continuing to develop in VS Code, we'll need to setup our Azure account.

  1. Create an Azure subscription. (A free trial will work)
  2. Create a Zero-Spend-Budget and a Cost Alert (Optional)
  3. Create a Resource Group in the Azure Portal
    • ⚠️ Select a Region that is also available in the Function App resource.⚠️
    • Optionally, you can test the Azure Region Latency to see which region is the best choice for your Azure resources. (Azure Speed Test)

Local Backend Setup

Next, we need to work on the backend side of the project. Here we will interchangeably develop in VS Code and create resources in Azure via the portal.

  1. Create a /backend/api folder in the root directory
  2. Install .NET SDK x64 LTS (Version 8.0.16 LTS)
    • Run dotnet --info to verify installation
    • ⚠️ Make sure you have the newly installed .NET SDK in the Environment Variables or uninstall an older version with caution.⚠️
    • Remember to reopen VS Code after .NET installation
  3. Install Azure Tools extension in VS Code
    ms-vscode.vscode-node-azure-pack
  4. Install the C# extension in VS Code
    ms-dotnettools.csharp
    ms-dotnettools.csdevkit
  5. Install the Azure Functions Core Tools .MSI x64 (Version 4.0.7030)
    • Run func --version to verify installation
  6. Create a Default C# Azure Function in VS Code
  7. Create a Cosmos DB Account for NoSQL
  8. Modify the Default Function API and Create the Visitor Counter API
    • Cosmos DB v2 Bindings
    • Create separate files for the model and services used in the main VisitorCounter.cs file
    • Install package: dotnet add package Microsoft.Azure.Functions.Worker.Extensions.CosmosDB in VS Code
    • Add a "CosmosDBConnectionString" key with the PRIMARY CONNECTION STRING value from your Cosmos DB Account in Azure in local.settings.json file

Local Backend and Frontend Integration

Lastly, to make everything work locally, we need to integrate our Visitor Counter API into our website.

  1. Create a Fetch API in JavaScript
    • ⚠️ Initially, use the local API url. However, remember to use the Function API URL after creating it in Azure.
  2. Enable CORS for Local Development
    • Add "Host": {"CORS": "*"} in local.settings.json file

Deployment to Azure

Frontend Part

After finishing our local frontend setup we can proceed with the deployment. (Know that many of the services we manually create can be done automatically using Azure Static Web Apps)

  1. Create a Storage Account in Azure (You should have a separate Storage Account for your backend and frontend)
    • Name the Storage Account the way you want your Static Website to be named
    • Primary service: Azure Blob Storage
    • Enable Static Website Hosting to be able to deploy your frontend code to Azure via VS Code
  2. Deploy Website from VS Code to Azure
    • >Azure Storage: Deploy to Static Website via Azure Storage...
  3. Create an Azure CDN Endpoint in your Storage Account
    • Origin hostname: Static website | Pricing tier: Standard Microsoft | Query string caching behavior: Ignore Query String
  4. Purchase and Configure a Custom Domain (This is the only service in the project that is not free)
    • I used Namecheap
    • Create two Host Records in the Advanced DNS section
      • Type: CNAME Record | Host: www | Value: <yourAzureCDNEndpoint>
      • Type: URL Redirect Record | Host: @ | Value: http://<yourCustomDomain>/ Unmasked
  5. Add your Custom Domain in your Azure Endpoint
    • Custom hostname: <yourCustomDomain>
  6. Enable Custom Domain HTTPS in your Azure Custom Domain
    • The certificate will be automatically created

Backend Part

After finishing our local backend setup we can proceed to deploy our API from VS Code to Azure

  1. Create a Storage Account in Azure (You'll need this for the Function App)
    • Name the Storage Account like your function
    • Primary service: Azure Blob Storage
    • V2 Storage Account
  2. Create a Function App in Azure (via Portal or VS Code)
    • Make sure to use the Advanced option and choose the correct Resource Group, if you create the Function App via VS Code
  3. Register the Microsoft.ManagedIdentity Resource Provider in Azure
    • Portal => Subscriptions => Settings => Resource providers => Microsoft.ManagedIdentiy => REGISTER
  4. Deploy API from VS Code to Azure
    • >Azure Functions: Deploy to Function App...
  5. Add the Custom Domain in the Function App CORS Allowed Origins List
    • This allows the VisitorCounter API to work with the Custom Domain
  6. Add the CosmosDBConnectionString value as an Environment Variable in the Function

Unit Tests Setup

We should implemented unit tests for the visitor counter feature. These tests focus specifically on the logic that increments the visitor count, isolating it from external dependencies like Cosmos DB.

  1. Create a backend/tests
  2. Unit Testing C# in .NET using dotnet test and xUnit
  3. Initialize Test Project
    • Run dotnet new xunit command in terminal
  4. Create the VisitorCounterServiceTests.cs file
  5. Add reference and packages
    • Run dotnet add reference ../api/api.csproj command in terminal
    • Run dotnet add package NSubstitute command in terminal
    • Run dotnet add package FluentAssertions command in terminal
  6. Test the code
    • Run dotnet test command in terminal

CI/CD Setup

Next, we will use GitHub Actions to automatically deploy code changes to Azure.

  1. Create Repository Secrets for your Azure Credentials
    • Settings => Secrets and variables => Actions => Repository secrets
    • AZURE_CLIENT_ID | AZURE_SUBSCRIPTION_ID | AZURE_TENANT_ID
  2. Create Frontend Workflow
  3. Create Backend Workflow

🚧 Coming Soon: Create IaC Files

About

Azure Cloud Resume Challenge

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages