Week 6 - Cloud and Azure Essentials

Introduction to Cloud and Azure

Azure CLI and the Portal

Azure Blob Storage

Azure PostgreSQL Databases

Azure Container Apps Jobs

Cost Awareness

Practice

Assignment: Deploy to Azure

Gotchas & Pitfalls

Slides (PDF)

Career relevance: Week 6

Glossary: Week 6

Going Further

History of Cloud Computing

Practice

<aside> ๐Ÿ“ These exercises combine concepts from multiple chapters. Use them to verify your understanding before starting the assignment.

</aside>

All five exercises run against the shared Azure infrastructure your teacher provisioned (rg-hyf-data). In class you will do Exercises 1-4 live (chapter by chapter); Exercise 5 (cost analysis) is optional homework.

<aside> ๐Ÿ–ผ๏ธ Visual: Week 6 end-to-end (ACR โ†’ Job โ†’ Blob + Postgres)

</aside>

Each exercise below links the matching diagram from the in-class slides.

<aside> โš ๏ธ Before you start, confirm:

If any of the above fails, ping your teacher before debugging your code: most "it does not work" reports at this stage are infrastructure-access problems, not bugs.

</aside>

Open the workspace once

All Week 6 exercises live under data-track/week-6/ in HYF's Learning-Resources repo. One Codespace covers all 5 exercises.

<aside> ๐Ÿ’ป Open in GitHub Codespaces

</aside>

The repo's data-track/.devcontainer/ boots Python 3.11 + ruff + Pylance for every exercise. From the Codespace's Explorer, navigate into data-track/week-6/exercise_N/.

Prefer your own VS Code? Clone locally instead:

git clone <https://github.com/HackYourFuture/Learning-Resources.git>
cd Learning-Resources/data-track/week-6
code .

Each exercise folder ships its own README.md. Python exercises use uv sync for dependencies.

Reference solutions (peek only after attempting)

Each exercise_N/solutions/ folder holds the answer in-place. The original # TODO comments are preserved, and # WHY ...: notes sit under each non-obvious choice.

Read the WHY notes, not the code. The point is the reasoning, not the syntax.

Spoiler discipline

Time-box yourself: 10โ€“30 minutes of honest attempt before you open solutions/. You can diff your attempt against the reference:

diff exercise_1/exercise.sh exercise_1/solutions/exercise.sh
diff exercise_3/exercise.py exercise_3/solutions/exercise.py

Exercise 1: Trace a resource group

Concepts: Azure CLI, resource hierarchy, cost awareness.

Instructions:

  1. Write a bash script that lists all resources in rg-hyf-data as a table.
  2. For each resource, identify: what type it is, which chapter introduced it, and whether it bills when idle.
  3. Fill in resource_table.md with columns: Resource Name, Type, Chapter, Bills When Idle (yes/no).

Why this helps: In the assignment, you will create resources yourself. Knowing what already exists prevents duplicates and wasted credits.

<aside> ๐Ÿ“ฆ Files: exercise_1/: bash exercise.sh lists resources; resource_table.md is your classification worksheet.

</aside>

Visual: resources in rg-hyf-data


Exercise 2: End-to-end blob verification

Concepts: Blob Storage (Python + CLI), naming conventions.

Instructions:

  1. Retrieve AZURE_STORAGE_CONNECTION_STRING from Key Vault and finish the Python upload script.
  2. Upload a JSON file to test/practice_<today>.json in the raw container.
  3. Use only the CLI to list, download, and verify the blob. Delete it when done.

Why this helps: The assignment requires you to verify pipeline output. This exercise practices the verification loop (upload from code, check from CLI) that you will use to prove your pipeline works.

<aside> ๐Ÿ“ฆ Files: exercise_2/: the starter exits with a clear message until Key Vault credentials are exported. Then run uv run python exercise.py.

</aside>

Visuals: Blob Storage hierarchy ยท three different "containers"


Exercise 3: Blob upload + Postgres ingest (both env vars)

Concepts: Dual env vars, Blob Storage + Postgres, schemas, DBeaver verification.

Instructions:

  1. Export both POSTGRES_URL and AZURE_STORAGE_CONNECTION_STRING from Key Vault.
  2. Upload weather_data.csv to raw/practice/<your_name>/ in Blob Storage.
  3. Ingest the same CSV into Postgres: personal schema (dev_<your_name>), practice_readings table, query results.
  4. Verify rows in DBeaver (Chapter 4): same connection as POSTGRES_URL, SET search_path TO dev_<your_name>;, then SELECT * FROM practice_readings.

Why this helps: The assignment writes to both storage targets using the same two env vars you pass to the Container App Job. This exercise is the end-to-end pattern in one script.

<aside> ๐Ÿ“ฆ Files: exercise_3/: run uv run python exercise.py after exporting both secrets. Do Ex2 first if you want blob upload in isolation.

</aside>

Visual: SQLite vs managed PostgreSQL

For risk-free pre-flight practice on connection-string anatomy, run the widget first.

<aside> ๐Ÿš€ Pre-flight in the widget: Parse Postgres URL exercise

</aside>


Exercise 4: Create a Container App Job

Concepts: Container Apps Jobs, Key Vault env vars, create vs start, gotchas.

Instructions:

  1. Look up your ACR image tag from Week 5 (hyfregistry.azurecr.io/<your-handle>-weather-pipeline:<tag>). If your image is missing, use the teacher's fallback hyfregistry.azurecr.io/weather-pipeline:assignment to practice the CLI workflow.
  2. Write the az containerapp job create command in exercise.sh using the shared values from Chapter 5 (rg-hyf-data, env-hyf-data, hyfregistry.azurecr.io).
  3. Run bash validate_flags.sh exercise.sh to check against the gotchas list before creating.
  4. Create the job with a unique name (job-practice-<your_name>), list jobs, and print the portal link.
  5. Start the job, then read logs (--container must match the job name, not the image name).
  6. If the run succeeded, verify outputs (blob list + Postgres/DBeaver), same loop as Ex2/Ex3.
  7. Delete your practice job when finished.

Why this helps: Missing --registry-server is the #1 Container Apps Job failure mode. Create โ‰  start is the second most common surprise. Validating flags first saves Azure credits.

<aside> ๐Ÿ“ฆ Files: exercise_4/: bash script + validate_flags.sh. See README.md for the full start/logs/verify flow. Pre-flight in the widget: Validate Container App Job create command.

</aside>

Visual: App vs Job lifecycle ยท local vs cloud env vars ยท deploy sequence


Exercise 5: Cost Analysis in the Azure Portal

Concepts: Cost awareness, portal navigation, idle billing.

Instructions:

  1. Run bash exercise.sh to verify az login and get the portal link for rg-hyf-data.
  2. Open Cost Management โ†’ Cost Analysis in the portal (month-to-date view).
  3. Fill in cost_findings.md: month-to-date total, top 3 cost drivers, and which resources bill when idle.
  4. Write one sentence on what would save the most money.

Why this helps: Postgres is the dominant cost in this setup. Reading live portal data connects the Chapter 6 pricing table to what you actually spend.

<aside> ๐Ÿ“ฆ Files: exercise_5/: portal worksheet (no Python SDK). Your group has Cost Management Reader on rg-hyf-data. Pre-flight widget for stop-vs-run arithmetic: Monthly cost in EUR exercise.

</aside>