Week 6 - Cloud and Azure Essentials
Introduction to Cloud and Azure
<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:
az login works and your active subscription is the shared HYF tenant (az account show).az keyvault secret show --vault-name kv-hyf-data --name postgres-url --query value -o tsvaz containerapp env show --name env-hyf-data --resource-group rg-hyf-data.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>
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.
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.
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
Concepts: Azure CLI, resource hierarchy, cost awareness.
Instructions:
rg-hyf-data as a table.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
Concepts: Blob Storage (Python + CLI), naming conventions.
Instructions:
AZURE_STORAGE_CONNECTION_STRING from Key Vault and finish the Python upload script.test/practice_<today>.json in the raw container.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"
Concepts: Dual env vars, Blob Storage + Postgres, schemas, DBeaver verification.
Instructions:
POSTGRES_URL and AZURE_STORAGE_CONNECTION_STRING from Key Vault.weather_data.csv to raw/practice/<your_name>/ in Blob Storage.dev_<your_name>), practice_readings table, query results.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>
Concepts: Container Apps Jobs, Key Vault env vars, create vs start, gotchas.
Instructions:
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.az containerapp job create command in exercise.sh using the shared values from Chapter 5 (rg-hyf-data, env-hyf-data, hyfregistry.azurecr.io).bash validate_flags.sh exercise.sh to check against the gotchas list before creating.job-practice-<your_name>), list jobs, and print the portal link.--container must match the job name, not the image name).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
Concepts: Cost awareness, portal navigation, idle billing.
Instructions:
bash exercise.sh to verify az login and get the portal link for rg-hyf-data.cost_findings.md: month-to-date total, top 3 cost drivers, and which resources bill when idle.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>