From e96ce45510b36570596dc06c8d21d600730666fc Mon Sep 17 00:00:00 2001 From: Digvijay Chauhan Date: Sun, 29 Nov 2026 12:47:14 +0100 Subject: [PATCH] Agentic SDLC: end-to-end verification and fixes I tested the Agentic SDLC MicroHack end to end the way participants will run it on the MicroHack platform: lab account in the event GitHub organization, fork of microhack, Codespace with the Azure / AI / Agentic SDLC configuration. ### What was verified - Codespace: build, `make dev` (API and frontend respond), and the test suites of all four API tracks (TypeScript, C#, Python, Java) plus the Playwright end-to-end tests. - The Copilot cloud agent picked up a seeded backlog issue and opened a pull request; Copilot code review then reviewed it and raised a real finding. - New lab automation deployed into a test subscription. ### What changed - Challenge 1 follows the same platform flow as the other GHCPUsers hacks: lab account, fork in the event organization, Codespace with the hack's dev container. - New `scripts/setup-fork.sh`: copies the hack's Copilot instructions, custom agents, skills and workflows to the fork root (the cloud agent, code review and Actions only read the repository root), checks that Issues are on, and removes the MicroHack PR compliance workflows from the fork. `deploy.yml` runs its steps in the hack folder. - Root dev container pinned to Ubuntu 24.04: `base:ubuntu` now resolves to 26.04, where Playwright cannot install Chromium, so `make test` failed in a fresh Codespace. - The cloud agent ran out of its session time when an issue was implemented in all four API tracks. Challenge 3 and the repository instructions now keep a task to one track (TypeScript API and frontend by default); with that, the agent finished in time. - New `labautomation/` (lab-defaults with GHCPUsers; an empty resource group per lab with Owner, in a region with Azure SRE Agent) for Challenges 5 and 6. - Copilot product names updated (Copilot cloud agent, Copilot CLI, custom agents, prompt files, skills, GitHub MCP server, `gh aw`), Challenge 4 test commands, Challenge 5 and 6 prerequisites with a no-Azure path, a coach checklist, Java 17 alignment, deploy scaffold fixes (API Dockerfile, `.dockerignore`, parameters, frontend API URL), Markdown preview in the Codespace. ### Worth a look - Coach checklist: the event organization must allow forking and have Copilot cloud agent, code review, MCP and Copilot CLI enabled by policy. A seat alone does not enable them. - Not tested live: the Challenge 5 Azure deployment workflow, the Challenge 6 SRE Agent and Challenge 7 agentic workflows (syntax and prerequisites checked only). ### How it was tested The lab was deployed with this hack's own `labautomation` into a test subscription (all test resources have since been deleted) and every challenge was run as a participant would. Links and the repository structure check pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Dockerfile | 3 +- .../devcontainer.json | 6 ++ .../.devcontainer/devcontainer.json | 1 + .../01-04-AI/01_Agentic_SDLC/.gitattributes | 2 + .../.github/copilot-instructions.md | 1 + .../.github/workflows/deploy.yml | 8 +- .../01_Agentic_SDLC/.vscode/launch.json | 4 +- .../01-04-AI/01_Agentic_SDLC/.vscode/mcp.json | 3 +- .../01_Agentic_SDLC/.vscode/tasks.json | 10 +-- 03-Azure/01-04-AI/01_Agentic_SDLC/Readme.md | 27 ++++--- .../challenges/challenge-01.md | 29 ++++--- .../challenges/challenge-02.md | 2 + .../challenges/challenge-03.md | 21 ++--- .../challenges/challenge-04.md | 41 +++++++--- .../challenges/challenge-05.md | 41 ++++++++-- .../challenges/challenge-06.md | 10 ++- .../challenges/challenge-07.md | 18 +++-- .../01-04-AI/01_Agentic_SDLC/infra/README.md | 74 ++++++++++++------ .../01-04-AI/01_Agentic_SDLC/infra/main.bicep | 41 +++++----- .../infra/main.parameters.json | 5 +- .../infra/modules/containerapp-env.bicep | 5 +- .../infra/modules/containerapp.bicep | 4 +- .../01_Agentic_SDLC/labautomation/README.md | 9 +++ .../labautomation/deploy-lab.ps1 | 62 +++++++++++++++ .../labautomation/lab-defaults.json | 10 +++ .../labautomation/shared-deploy-lab.ps1 | 33 ++++++++ .../01_Agentic_SDLC/scripts/README.md | 19 ++++- .../01_Agentic_SDLC/scripts/setup-fork.sh | 76 +++++++++++++++++++ .../01_Agentic_SDLC/src/.dockerignore | 16 ++++ .../01-04-AI/01_Agentic_SDLC/src/Makefile | 2 +- .../01-04-AI/01_Agentic_SDLC/src/README.md | 17 ++++- .../Repositories/SuppliersRepositoryTests.cs | 5 ++ .../01_Agentic_SDLC/src/api-ts/Dockerfile | 14 ++-- .../01_Agentic_SDLC/src/api-ts/package.json | 3 +- .../src/api-ts/src/generate-swagger.ts | 2 +- .../walkthrough/challenge-01/solution-01.md | 11 +-- .../walkthrough/challenge-02/solution-02.md | 1 + .../walkthrough/challenge-03/solution-03.md | 8 +- .../walkthrough/challenge-04/solution-04.md | 5 +- .../walkthrough/challenge-05/solution-05.md | 10 ++- .../walkthrough/challenge-06/solution-06.md | 4 +- .../walkthrough/challenge-07/solution-07.md | 7 +- 42 files changed, 520 insertions(+), 150 deletions(-) create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/.gitattributes create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/README.md create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/deploy-lab.ps1 create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/lab-defaults.json create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/shared-deploy-lab.ps1 create mode 100755 03-Azure/01-04-AI/01_Agentic_SDLC/scripts/setup-fork.sh create mode 100644 03-Azure/01-04-AI/01_Agentic_SDLC/src/.dockerignore diff --git a/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/Dockerfile b/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/Dockerfile index daf5a4d8f..a72499e62 100644 --- a/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/Dockerfile +++ b/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/Dockerfile @@ -1,4 +1,5 @@ -FROM mcr.microsoft.com/devcontainers/base:ubuntu +# Ubuntu 24.04: Playwright (Challenge 4) does not support newer releases yet. +FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04 RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/devcontainer.json b/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/devcontainer.json index 36b5dc244..ebe348977 100644 --- a/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/devcontainer.json +++ b/.devcontainer/03-azure-01-04-ai-01-agentic-sdlc/devcontainer.json @@ -80,6 +80,12 @@ ], "settings": { "terminal.integrated.defaultProfile.linux": "bash", + "git.openRepositoryInParentFolders": "always", + "workbench.editorAssociations": { + "**/01_Agentic_SDLC/Readme.md": "vscode.markdown.preview.editor", + "**/01_Agentic_SDLC/challenges/*.md": "vscode.markdown.preview.editor", + "**/01_Agentic_SDLC/walkthrough/**/*.md": "vscode.markdown.preview.editor" + }, "editor.inlineSuggest.experimentalInlineEditsEnabled": true, "github.copilot.chat.advanced.inlineEdits.enabled": true, "github.copilot.chat.agent.enabled": true, diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.devcontainer/devcontainer.json b/03-Azure/01-04-AI/01_Agentic_SDLC/.devcontainer/devcontainer.json index 91e97034f..8fb8667f6 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.devcontainer/devcontainer.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.devcontainer/devcontainer.json @@ -56,6 +56,7 @@ "extensions": [ "ms-azuretools.vscode-docker", "GitHub.copilot", + "GitHub.copilot-chat", "ms-vscode.extension-test-runner", "vitest.explorer", "ms-vscode.vscode-speech", diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.gitattributes b/03-Azure/01-04-AI/01_Agentic_SDLC/.gitattributes new file mode 100644 index 000000000..99e37e956 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.gitattributes @@ -0,0 +1,2 @@ +# Shell scripts run inside Linux containers and Codespaces. Keep LF endings on Windows checkouts. +*.sh text eol=lf diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.github/copilot-instructions.md b/03-Azure/01-04-AI/01_Agentic_SDLC/.github/copilot-instructions.md index 4f976496f..e22a9f90f 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.github/copilot-instructions.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.github/copilot-instructions.md @@ -29,6 +29,7 @@ When generating suggestions: - Build and test via the `src/Makefile` (run targets from `src/`): `make build` / `make test` / `make dev` cover all variants, and per-language targets like `make build-ts`, `make test-ts`, `make dev-ts` scope to one implementation. - Install dependencies with the install targets: `make install` (everything) or per-language `make install-ts`, `make install-cs`, `make install-py`, `make install-java`, `make install-frontend`. - Keep PRs scoped: code + tests + docs (architecture or build notes) when behavior changes. +- Change only the API track the task names. If a task names none, change the TypeScript API (`src/api-ts`) and the frontend only; do not port the change to the C#, Python or Java APIs unless asked. - Update related instruction files if new folders or architectural slices are introduced. ## Do Not Repeat diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.github/workflows/deploy.yml b/03-Azure/01-04-AI/01_Agentic_SDLC/.github/workflows/deploy.yml index 025f7143f..f7825a4ec 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.github/workflows/deploy.yml +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.github/workflows/deploy.yml @@ -56,6 +56,10 @@ jobs: deploy: name: Provision & deploy runs-on: ubuntu-latest + # The app lives in the hack folder of your MicroHack fork, so every `run` step starts there. + defaults: + run: + working-directory: 03-Azure/01-04-AI/01_Agentic_SDLC # TODO: Consider binding to a GitHub Environment (e.g. `environment: dev`) so # you can add reviewers/approval gates and environment-scoped secrets. steps: @@ -81,14 +85,14 @@ jobs: # (b) let the Bicep create it, then read ACR_NAME from a deployment output # and split this into "provision infra" -> "build/push" -> "update apps". # The two build contexts and their Dockerfiles are: - # - API: context src/api-ts Dockerfile src/api-ts/Dockerfile (port 3000) + # - API: context src Dockerfile src/api-ts/Dockerfile (port 3000; needs src/database) # - Frontend: context src/frontend Dockerfile src/frontend/Dockerfile (port 80) - name: Build & push images to ACR run: | echo "TODO: build and push both images" # az acr login --name "$ACR_NAME" # LOGIN_SERVER="$ACR_NAME.azurecr.io" - # docker build -t "$LOGIN_SERVER/api:$IMAGE_TAG" -f src/api-ts/Dockerfile src/api-ts + # docker build -t "$LOGIN_SERVER/api:$IMAGE_TAG" -f src/api-ts/Dockerfile src # docker build -t "$LOGIN_SERVER/frontend:$IMAGE_TAG" -f src/frontend/Dockerfile src/frontend # docker push "$LOGIN_SERVER/api:$IMAGE_TAG" # docker push "$LOGIN_SERVER/frontend:$IMAGE_TAG" diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/launch.json b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/launch.json index e9c94ae40..c3179351a 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/launch.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/launch.json @@ -5,7 +5,7 @@ "type": "node", "request": "launch", "name": "Debug API", - "cwd": "${workspaceFolder}/api", + "cwd": "${workspaceFolder}/src/api-ts", "runtimeExecutable": "npm", "runtimeArgs": ["run", "dev"], "console": "integratedTerminal", @@ -14,7 +14,7 @@ "type": "node", "request": "launch", "name": "Start Frontend", - "cwd": "${workspaceFolder}/frontend", + "cwd": "${workspaceFolder}/src/frontend", "runtimeExecutable": "npm", "runtimeArgs": ["run", "dev"], "console": "integratedTerminal", diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/mcp.json b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/mcp.json index a889cd4a9..8b7b610fb 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/mcp.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/mcp.json @@ -12,7 +12,8 @@ "command": "npx", "args": [ "@playwright/mcp@latest", - "--browser=msedge" + "--browser=chromium", + "--headless" ], "type": "stdio" }, diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/tasks.json b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/tasks.json index 27c7c9319..e46f1546f 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/tasks.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/.vscode/tasks.json @@ -10,7 +10,7 @@ "build" ], "options": { - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}/src" }, "group": { "kind": "build", @@ -22,10 +22,10 @@ "type": "shell", "command": "make", "args": [ - "build-api" + "build-ts" ], "options": { - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}/src" }, "presentation": { "reveal": "always", @@ -43,7 +43,7 @@ "build-frontend" ], "options": { - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}/src" }, "presentation": { "reveal": "always", @@ -52,7 +52,7 @@ "problemMatcher": [ "$tsc" ] - }, + } ], "inputs": [ ] diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/Readme.md b/03-Azure/01-04-AI/01_Agentic_SDLC/Readme.md index f5106fa29..dd0610c33 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/Readme.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/Readme.md @@ -22,7 +22,7 @@ flowchart LR F --> G[Maintain] G -.-> A subgraph Agents - Copilot[GitHub Copilot / Copilot App] + Copilot[GitHub Copilot: agent mode, cloud agent, code review] Actions[GitHub Actions CI/CD] SRE[Azure SRE Agent] GHAW[GitHub Agentic Workflows] @@ -43,7 +43,7 @@ This lab is **not** a full explanation of GitHub Copilot or Azure as technologie - [Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/) - [Azure SRE Agent](https://learn.microsoft.com/en-us/azure/sre-agent/) -> **What's included.** This MicroHack folder is **self-contained** — everything you need ships with it: the **Octocat Supply** application source ([`src/`](src/README.md)), the Azure infrastructure scaffold ([`infra/`](infra/README.md)), helper [`scripts/`](scripts/README.md), the dev containers ([`.devcontainer/`](.devcontainer/)), the editor config ([`.vscode/`](.vscode/)), and the repo custom instructions, custom agents, and workflows ([`.github/`](.github/)). The Challenge 3 inputs — the product backlog and the mock **WorkIQ** organizational knowledge (Teams thread, support-ticket digest, stakeholder email) — live under [`assets/`](assets/). Facilitators create a copy/fork of this MicroHack per team before the event; participants work in their team's copy. +> **What's included.** This MicroHack folder is **self-contained**: everything you need ships with it: the **Octocat Supply** application source ([`src/`](src/README.md)), the Azure infrastructure scaffold ([`infra/`](infra/README.md)), helper [`scripts/`](scripts/README.md), the dev containers ([`.devcontainer/`](.devcontainer/)), the editor config ([`.vscode/`](.vscode/)), and the repo custom instructions, custom agents, and workflows ([`.github/`](.github/)). The Challenge 3 inputs (the product backlog and the mock **WorkIQ** organizational knowledge (Teams thread, support-ticket digest, stakeholder email) live under [`assets/`](assets/). In Challenge 1 each participant forks the `microhack` repository in the event organization, opens it in a Codespace with the **Azure / AI / Agentic SDLC** configuration, and runs `scripts/setup-fork.sh` once. ## MicroHack context @@ -70,16 +70,25 @@ This MicroHack has a few but important prerequisites. Completing them before the In summary: -- A **GitHub account** with access to your team's copy of this MicroHack repo and an **active GitHub Copilot seat** (Copilot Business/Enterprise, with Chat, agents, CLI, and MCP policies enabled). -- Either **GitHub Codespaces** (recommended — nothing to install) **or** local **VS Code** with the **Dev Container** plus the **GitHub Copilot / Copilot Chat** extensions. The container preinstalls **Node.js 24, Python 3.13, .NET 10, Java 17**. -- For **Challenges 5 & 6**, **Azure access**: - - An **Azure subscription** with budget. +- The **hackathon-provided GitHub account** from your lab credentials. For each event the MicroHack platform creates a GitHub organization and allocates Copilot seats to lab accounts, which are Entra managed users (EMU). You fork the `microhack` repository inside that organization in [Challenge 1](challenges/challenge-01.md). Running the hack outside the platform? Any GitHub account with an active Copilot license (Business, Enterprise, Pro or Pro+) works; for Business and Enterprise your admin must enable the policies in the coach checklist below. +- **GitHub Codespaces** in the event organization (recommended, nothing to install) **or** local **VS Code** with the **Dev Containers** extension and Docker. The dev container preinstalls **Node.js 24, Python 3.13, .NET 10, Java 17**, the GitHub CLI, the Azure CLI, and the GitHub Copilot and Copilot Chat extensions. +- For **Challenges 5 & 6** only, **Azure access**: + - An **Azure subscription** with budget. On the MicroHack platform each lab gets an empty resource group with Owner rights (lab credentials **ResourceGroupName** and **AzureRegion**, see [`labautomation/`](labautomation/README.md)). - A **Resource Group** for the team. - - **Contributor** permissions on that scope (plus any roles the Azure SRE Agent needs on the monitored resources). - - A GitHub ↔ Azure **OIDC federated credential** for pipeline authentication. + - **Owner** on that scope, or **Contributor** plus **User Access Administrator**. The OIDC setup and the Azure SRE Agent both create role assignments. + - A GitHub ↔ Azure **OIDC federated credential** for pipeline authentication (`scripts/setup-oidc.sh` creates it). - **Azure SRE Agent** available in the team's region/subscription. -> Facilitators: work through the pre-event admin checklist (Copilot enablement, repo access, backlog issue seeding, Azure prerequisites) before running the event. +> **Running with Copilot licenses only.** Challenges 1 to 4 and 7 need no Azure. Challenge 5 has a [no-Azure path](challenges/challenge-05.md#no-azure-path) (green CI run plus a compiling template), and Challenge 6 has a local detect, diagnose, remediate loop. The full day works without an Azure subscription. + +### Coach checklist (before the event) + +- Every participant has received a hackathon-provided GitHub account (lab account) with a Copilot seat, and can sign in to it on the event network. +- The MicroHack platform assigns the Copilot seats. Confirm in the event organization (**Settings** > **Copilot** > **Policies**, or ask the platform team) that these are enabled, because a seat alone does not turn them on: **Copilot in the IDE** (Chat and agent mode), **MCP servers in Copilot**, **Copilot cloud agent** (formerly coding agent, Challenge 3), **Copilot code review** (Challenge 4), and **Copilot CLI** (Challenge 3 stretch and the GitHub Copilot app). +- Lab accounts can create repositories and **Codespaces** in the event organization. Forks must be owned by the organization, not by the lab account itself: lab accounts are Entra managed users, and the Copilot cloud agent is not available in repositories a managed user owns personally. Forking of the `microhack` repository within the organization must be allowed. +- **GitHub Actions** is allowed for those repositories (Challenges 3, 5, and 7 run in Actions). +- Do a dry run **with one lab account**, a day before: fork `microhack` in the event organization, open a Codespace with the **Azure / AI / Agentic SDLC** configuration, run `bash scripts/setup-fork.sh`, `bash scripts/seed-backlog.sh`, `cd src && make dev` and `make test`, assign one issue to Copilot, and request a Copilot review on a pull request. +- If you run the Azure path: the platform creates one resource group per lab with Owner rights in an SRE Agent region. Check that `sre.azure.com` and `*.azuresre.ai` are reachable on the event network, and delete the SRE Agents afterwards. ### Challenges diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-01.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-01.md index e6d28f75a..ba67a8e85 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-01.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-01.md @@ -2,9 +2,7 @@ **[Home](../Readme.md)** - [Next Challenge](challenge-02.md) -> **⚠️ Important — before you start.** Log into GitHub using the **hackathon-provided GitHub account** (labuser-0000_ms000000 — not your personal or corporate account), then **fork the MicroHack repo** in the MngEnvMCAP000000 organization with MngEnvMCAP000000 account as the **owner** of the fork. Remember to append "-labuser-0000" to the fork name to avoid conflicts. All later challenges — commits, pull requests, Actions runs, and OIDC federation — assume you're working from that fork under the hackathon account. -> -> When you create your Codespace, the repo offers **many** dev container configurations (one per MicroHack track). Do **not** create a Codespace with default settings. Select **"New with options..."**, then be sure to select **"Azure / AI / Agentic SDLC"** from the configuration picker — picking the wrong one (or the default) leaves you without the tools this track needs. +> **Before you start.** Sign in to GitHub with the **hackathon-provided GitHub account** from your lab credentials (for example `labuser-0000_ms000000`), not your personal or corporate account. That account has a GitHub Copilot seat and belongs to the **event organization** assigned to your lab. You work in your own fork of the `microhack` repository in that organization. ## Goal @@ -14,23 +12,29 @@ The Octocat team is behind schedule and adopting Agentic Development practices. ## Actions -* **Get the code** — Open your team's copy of this MicroHack in **GitHub Codespaces** (recommended), a local **VS Code Dev Container** (`.devcontainer/`), or locally. Confirm you're on the intended working branch. -* **Verify runtimes** — Confirm the runtimes for your chosen API track are available (TypeScript, Python, .NET, or Java) plus Node.js for the frontend. In Codespaces / the Dev Container these are preinstalled. -* **Enable GitHub Copilot** — Sign in and confirm your Copilot entitlement is active in your IDE; install the GitHub Copilot / Copilot Chat extensions. -* **Explore the repo** — Review the structure: `src/` (the app, with `src/docs/` architecture guidance), `infra/` + `scripts/` (Azure setup and deployment), `assets/` (Challenge 3 backlog & WorkIQ inputs), and `.github/` (Copilot custom instructions & agents). Identify where the frontend, APIs, and database live. Read `src/README.md` for the code structure and build commands. -* **Run the app locally** — Start the frontend and one API to confirm the application builds and runs before you begin changing it. +* **Fork the repository**: on github.com, open the event organization assigned to your lab account (your avatar > **Organizations**), then open the `microhack` repository and select **Fork**. Choose the organization as the owner and give the fork a unique name by appending your lab user, for example `microhack-labuser-0000`. On the fork, open **Settings** > **General** > **Features** and tick **Issues**, then open the **Actions** tab and select **I understand my workflows, go ahead and enable them**. Forks start with both turned off. +* **Open a Codespace**: on your fork, select **Code** > **Codespaces** > **...** > **New with options**. For **Dev container configuration** select **Azure / AI / Agentic SDLC**, not the default, then select **Create codespace**. The first start takes about 5 to 10 minutes because it runs `make install` and `make build`. +* **Set up your fork**: in the Codespace terminal run `bash scripts/setup-fork.sh`. It points the GitHub CLI at your fork, checks that Issues are on, and copies this hack's Copilot instructions, custom agents, skills and workflows to the root `.github/` folder of the fork, because the Copilot cloud agent, Copilot code review and GitHub Actions only read the repository root. It commits and pushes that change for you. +* **Seed the backlog**: run `bash scripts/seed-backlog.sh`. It creates the 8 backlog items from `assets/backlog.md` as labelled GitHub Issues in your fork, which you use in Challenge 3. Use `--dry-run` first if you want to preview. + +> If `gh` reports that it is not signed in or a permission error, run `unset GITHUB_TOKEN`, then `gh auth login` (GitHub.com, HTTPS, log in with a web browser, using the lab account), and run the script again. +* **Verify runtimes**: confirm `node --version`, `python --version`, `dotnet --version`, and `java -version` work. The dev container preinstalls Node.js 24, Python 3.13, .NET 10, and Java 17. You only need the runtime of the API track you pick plus Node.js for the frontend. +* **Enable GitHub Copilot**: open the **Chat** view in VS Code, switch the mode picker to **Agent**, and ask a question about a file. A real answer proves your license works. +* **Explore the repo**: review `src/` (the app, with `src/docs/` architecture guidance), `infra/` and `scripts/` (Azure setup and deployment), `assets/` (Challenge 3 backlog and WorkIQ inputs), and `.github/` (Copilot custom instructions, custom agents, and workflows). Read `src/README.md` for the code structure and build commands. +* **Run the app**: in a terminal run `cd src && make dev`. It starts the TypeScript API on port **3000** and the frontend on port **5137**. Open port 5137 from the **Ports** tab. In a Codespace the browser calls the API through the forwarded URL of port 3000, so port 3000 must be **Public** (the dev container sets this; if the Products page stays empty, right-click port 3000 in the **Ports** tab and set **Port Visibility** > **Public**). To run another API track use `make dev-cs`, `make dev-py`, or `make dev-java` (run `make install-cs`, `make install-py`, or `make install-java` once first). Stop the app with `Ctrl+C`. ## Success criteria -* Your team's repo copy is open in your environment and Copilot is active and responding in your IDE. -* You can build and run the frontend and at least one API locally. +* Your fork is open in a Codespace with the **Azure / AI / Agentic SDLC** configuration, and Copilot Chat in agent mode is responding. +* `setup-fork.sh` has run and the backlog issues exist in your fork. +* You can build and run the frontend and at least one API. * You can describe, at a high level, how the frontend, APIs, and database fit together. ### Optional stretch — repo-wide agent context Give Copilot persistent, repo-wide context so later challenges start with your conventions loaded. -* Create an `AGENTS.md` and/or `.github/copilot-instructions.md` recording coding conventions, naming, and preferred patterns. +* Extend `.github/copilot-instructions.md` (it already exists; after editing, run `bash scripts/setup-fork.sh` again to copy it to the repository root) and/or add an `AGENTS.md` recording coding conventions, naming, and preferred patterns. * Record the exact **build and test commands** for your API track (and the frontend) so an agent can verify its own work. * Add explicit **scope rules** (e.g. don't touch generated files, infra, unrelated services) to keep agent diffs minimal. * In a fresh Copilot Chat, ask a question that relies on those conventions **without restating them** and confirm they're applied. @@ -39,5 +43,6 @@ Give Copilot persistent, repo-wide context so later challenges start with your c * [Setting up GitHub Copilot](https://docs.github.com/en/copilot/quickstart) * [GitHub Codespaces](https://docs.github.com/en/codespaces/overview) +* [Fork a repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) * [Development Containers](https://containers.dev/) -* [Adding repository custom instructions for Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) +* [Adding repository custom instructions for Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-02.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-02.md index a6446627e..910e39f71 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-02.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-02.md @@ -8,6 +8,8 @@ Deliver a new feature for the Octocat Supply application by completing the incom The shopping cart is incomplete and lacks payment integration, which is blocking the launch. The focus of this challenge is **using Copilot well** — giving it the right context and iterating — not just writing code. +> Work in **VS Code Copilot Chat in agent mode**: open the **Chat** view and set the mode picker to **Agent**. The agent can read files, edit across the stack, and run terminal commands such as `make build-ts`. Review each change before you keep it. + ## Actions * **Understand the current state** — Review the existing cart-related code in the frontend and API. Use Copilot to explain what exists and what's missing. diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-03.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-03.md index ae3e8ed41..f1224b07f 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-03.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-03.md @@ -8,11 +8,13 @@ Pick up an additional feature from the Octocat Supply backlog and deliver it wit ## Actions -* **Choose a backlog item** — Pick a meaningful feature from `assets/backlog.md` (e.g. payment integration for the cart, order history, product search/filtering, or inventory management). A set of these may already be seeded as **GitHub Issues** in your repo — check the Issues tab and pick one. -* **Plan with an agent** — Use GitHub Copilot to break the work into steps and identify the files and layers involved (frontend, API, database) **before** writing code. -* **Implement** — Build the feature across the stack, keeping changes consistent with existing patterns and type-safe. -* **Add tests** — Cover the new logic with unit tests (API/repository) and component tests where relevant. -* **Review** — Use Copilot to review your own change before considering it done. +* **Choose a backlog item**: Pick a meaningful feature from `assets/backlog.md` (e.g. payment integration for the cart, order history, product search/filtering, or inventory management). You seeded these as **GitHub Issues** in Challenge 1. Check the Issues tab and pick one. +* **Plan with an agent**: Use GitHub Copilot to break the work into steps and identify the files and layers involved (frontend, API, database) **before** writing code. +* **Implement**: Build the feature across the stack, keeping changes consistent with existing patterns and type-safe. Choose where the agent runs: + * **VS Code Copilot Chat in agent mode** in your Codespace. You watch and steer each step. + * **Copilot cloud agent** (formerly Copilot coding agent) on github.com. Open the issue, select **Assignees** > **Copilot**, add an optional prompt, and select **Assign**. Keep the task small: in the prompt name **one** API track, for example *Implement this in the TypeScript API (`src/api-ts`) and the frontend only, with tests*. A session has a time limit of about an hour, and an issue that touches all four API tracks can run out of time before the pull request is ready. Copilot works in the background in GitHub Actions and opens a pull request for you to review. Comment `@copilot ...` on the pull request to ask for changes. +* **Add tests**: Cover the new logic with unit tests (API/repository) and component tests where relevant. +* **Review**: Use Copilot to review your own change before considering it done. ## Success criteria @@ -23,12 +25,13 @@ Pick up an additional feature from the Octocat Supply backlog and deliver it wit ### Optional stretch — harnesses, MCP & requirement refinement -* **Compare harnesses** — Run the planning step twice: once in **Copilot CLI** and once in the **Copilot App / IDE chat**. Note which gave the more implementation-ready plan for a quick fix vs. a multi-file change, and write down a decision rule. -* **Wire in an MCP server** — Connect one MCP server (e.g. the **GitHub MCP server**) to pull real backlog context such as issues and PRs. Note what stays local-only vs. what the server can see. -* **Refine a requirement from organizational signal** — Point your agent at `assets/workiq/` — the mock **WorkIQ** organizational knowledge (Teams thread, support-ticket digest, stakeholder email). Have it synthesize the signal across those artifacts, separate a genuinely-new need from noise and from work **already in the backlog**, and shape one unmet need into an **issue-ready requirement**: problem statement → acceptance criteria → scoped tasks (optionally opening it as a GitHub Issue). There's no answer key — the skill is the refinement. A ready-made **Requirement Refiner** custom agent (`.github/agents/`) can guide this. +* **Compare harnesses**: Run the planning step twice: once in **GitHub Copilot CLI** and once in **VS Code Copilot Chat in agent mode**. In the Codespace terminal, install the CLI with `npm install -g @github/copilot` and start it with `copilot`. If you have the **GitHub Copilot app** (desktop) installed locally, you can use it as a third harness. Note which gave the more implementation-ready plan for a quick fix vs. a multi-file change, and write down a decision rule. +* **Wire in an MCP server**: `.vscode/mcp.json` already configures the hosted **GitHub MCP server** as `github-remote`. Open the file, select **Start** above the server, and sign in to GitHub when asked. Then let the agent pull real backlog context such as issues and PRs. Note what stays local-only vs. what the server can see. +* **Refine a requirement from organizational signal**: Point your agent at `assets/workiq/`, the mock **WorkIQ** organizational knowledge (Teams thread, support-ticket digest, stakeholder email). Have it synthesize the signal across those artifacts, separate a genuinely-new need from noise and from work **already in the backlog**, and shape one unmet need into an **issue-ready requirement**: problem statement → acceptance criteria → scoped tasks (optionally opening it as a GitHub Issue). There's no answer key. The skill is the refinement. A ready-made **Requirement Refiner** custom agent (`.github/agents/requirement-refiner.agent.md`) can guide this. Select it from the agent picker in the VS Code **Chat** view. ## Learning resources -* [About GitHub Copilot coding agent](https://docs.github.com/en/copilot/using-github-copilot/coding-agent) +* [Get started with Copilot agents on GitHub (cloud agent)](https://docs.github.com/en/copilot/how-tos/copilot-on-github/use-copilot-agents/overview) +* [About GitHub Copilot CLI](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli) * [Extending Copilot Chat with the Model Context Protocol (MCP)](https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-chat-with-mcp) * [GitHub MCP server](https://github.com/github/github-mcp-server) diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-04.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-04.md index 09decdb23..8dc20a9f5 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-04.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-04.md @@ -8,11 +8,34 @@ Bring the testing and review of the application up to Octocat standards by runni ## Actions -* **Run the existing tests** — Execute the current API and frontend test suites and confirm the baseline passes. -* **Find the gaps** — Use Copilot to identify untested code paths, especially around the new cart and backlog features. -* **Extend coverage** — Add unit tests for repository/business logic and component tests for critical UI paths. Include edge cases and error handling. -* **Review the code** — Use Copilot (and/or the code review agent) to review recent changes for correctness, security, and data integrity. -* **Fix what you find** — Address issues surfaced by the tests and review, prioritising security and correctness over style. +* **Run the existing tests**: Execute the current API and frontend test suites and confirm the baseline passes (see [Test commands](#test-commands)). +* **Find the gaps**: Use Copilot to identify untested code paths, especially around the new cart and backlog features. +* **Extend coverage**: Add unit tests for repository/business logic and component tests for critical UI paths. Include edge cases and error handling. +* **Review the code**: Use Copilot to review recent changes for correctness, security, and data integrity. Two options: ask **Copilot Chat in agent mode** to review your diff, or push a branch, open a pull request, and request **Copilot** under **Reviewers** (Copilot code review). Copilot code review uses `.github/copilot-instructions.md` and `.github/instructions/*.instructions.md` from your repository. +* **Fix what you find**: Address issues surfaced by the tests and review, prioritising security and correctness over style. + +## Test commands + +Run these from the `src/` folder. The last column shows what each target runs. + +| What | Command | Underlying command | +| --- | --- | --- | +| TypeScript API unit tests (Vitest, runs once) | `make test-ts` | `cd api-ts && npm test` | +| TypeScript API coverage report | `make test-coverage` | `cd api-ts && npm run test:coverage` | +| C# API tests (xUnit) | `make test-cs` | `cd api-cs-tests && dotnet test` | +| Python API tests (pytest) | `make test-py` | `cd api-py && .venv/bin/python -m pytest` (run `make install-py` once first) | +| Java API tests (JUnit) | `make test-java` | `cd api-java && mvn test` | +| Frontend end-to-end tests (Playwright, Chromium) | `make test-e2e` | `cd frontend && npx playwright test` | +| TypeScript API + end-to-end tests | `make test` | both of the above | +| Lint TypeScript API + frontend | `make lint` | `npm run lint` in both folders | + +Notes for the Playwright end-to-end tests: + +* The first run of `make test-e2e` downloads Chromium and its Linux libraries (about 1 to 2 minutes). If you run `npx playwright test` directly, run `npx playwright install --with-deps chromium` once first. +* You do not need to start the app first. `src/frontend/playwright.config.ts` has a `webServer` entry that runs `make dev` and waits for port 5137. Because `reuseExistingServer` is `!process.env.CI`, a dev server that is already running is reused. When the `CI` variable is set (for example in GitHub Actions), Playwright starts its own server and fails if port 5137 is already in use. +* Set `PLAYWRIGHT_WEB_SERVER=false` to skip the built-in server, and `PLAYWRIGHT_BASE_URL` to test another URL. +* In a Codespace the browser calls the API through the forwarded URL of port 3000. If the product tests time out, check that port 3000 is **Public** in the **Ports** tab. +* The frontend has no unit or component test setup yet, but Vitest, Testing Library, and jsdom are already dev dependencies in `src/frontend/package.json`. Adding a small Vitest config (jsdom environment, excluding `tests/e2e`) for component tests is allowed. It is not a new framework. ## Success criteria @@ -24,12 +47,12 @@ Bring the testing and review of the application up to Octocat standards by runni ### Optional stretch — model selection & context budgeting -* **Compare models** — Generate tests for the same code once in **Auto** mode and once with an **explicitly selected model**. Compare and record a decision rule for when to use each. -* **Set a context budget** — Before prompting, decide a budget (max number of files, max reference length per file) and stick to it. -* **Note the trade-off** — Capture how the budget affected quality vs. noise in the generated tests. +* **Compare models**: Generate tests for the same code once in **Auto** mode and once with an **explicitly selected model**. Compare and record a decision rule for when to use each. +* **Set a context budget**: Before prompting, decide a budget (max number of files, max reference length per file) and stick to it. +* **Note the trade-off**: Capture how the budget affected quality vs. noise in the generated tests. ## Learning resources -* [Configuring GitHub Copilot code review](https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review) +* [Using GitHub Copilot code review on GitHub](https://docs.github.com/en/copilot/how-tos/copilot-on-github/use-copilot-agents/copilot-code-review) * [Writing tests with GitHub Copilot](https://docs.github.com/en/copilot/using-github-copilot/guides-on-using-github-copilot/writing-tests-with-github-copilot) * [Changing the AI model for Copilot Chat](https://docs.github.com/en/copilot/using-github-copilot/ai-models/changing-the-ai-model-for-copilot-chat) diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-05.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-05.md index 4282d8b29..5e1163294 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-05.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-05.md @@ -6,22 +6,47 @@ Deploy the full Octocat Supply application to **Microsoft Azure** using **Infrastructure as Code (IaC)** and a **GitHub Actions** CI/CD pipeline. The deployment should be automated, repeatable, defined as code, and driven from GitHub Actions. +## Before you start + +You need all of these for the Azure path: + +* An **Azure subscription** you can deploy to, and a **resource group** for your team. On the MicroHack platform this is ready for you: the lab credentials show **ResourceGroupName** and **AzureRegion**, and you are Owner on that resource group. Sign in with the lab account (`az login --use-device-code`). +* **Owner** on that resource group, or **Contributor** plus **User Access Administrator**. Contributor alone can deploy, but it cannot create the role assignment the pipeline identity needs. +* A GitHub to Azure **OIDC federated credential**, so the workflow can sign in without a stored secret. [`scripts/setup-oidc.sh`](../scripts/setup-oidc.sh) creates a user-assigned managed identity, grants it Contributor on the resource group, adds the federated credential for your repo, and sets the `AZURE_*` secrets and variables. In the Codespace run `az login --use-device-code`, then `bash scripts/setup-oidc.sh -g -l `. If it cannot write the GitHub secrets, it prints the values so you can add them under **Settings** > **Secrets and variables** > **Actions**. +* `scripts/setup-fork.sh` from [Challenge 1](challenge-01.md) has run, so `deploy.yml` sits in the root `.github/workflows/` folder of your fork (GitHub Actions only runs workflows from there) and Actions is turned on. Edit the workflow at the repository root, not the copy in this hack folder. Its `run` steps already start in the hack folder (`defaults.run.working-directory`). + +> **No Azure subscription?** Do the [no-Azure path](#no-azure-path) below instead. You still practise the agentic part: authoring IaC and a pipeline with Copilot. + ## Actions -* **Choose your IaC** — Define the Azure infrastructure using an IaC approach (e.g. **Bicep** or **Terraform**) for the resources the app needs: compute for frontend/API, storage/database, and supporting services. -* **Author the templates** — Use Copilot to help generate and refine the IaC, following Azure best practices. -* **Build the pipeline** — Create a GitHub Actions workflow that builds, tests, provisions infrastructure, and deploys the frontend and API. -* **Configure securely** — Use GitHub secrets / **OIDC federated credentials** for Azure authentication; avoid hard-coded credentials. -* **Deploy and verify** — Run the pipeline and confirm the application is reachable in Azure. +* **Choose your IaC**: Define the Azure infrastructure using an IaC approach (e.g. **Bicep** or **Terraform**) for the resources the app needs: compute for frontend/API, storage/database, and supporting services. +* **Author the templates**: Use Copilot to help generate and refine the IaC, following Azure best practices. +* **Build the pipeline**: Create a GitHub Actions workflow that builds, tests, provisions infrastructure, and deploys the frontend and API. +* **Configure securely**: Use GitHub secrets / **OIDC federated credentials** for Azure authentication; avoid hard-coded credentials. +* **Deploy and verify**: Run the pipeline and confirm the application is reachable in Azure. -> **Optional starter scaffold (included in this folder).** [`infra/`](../infra/README.md) (Bicep) — bundled here — plus the bundled [`.github/workflows/deploy.yml`](../.github/workflows/deploy.yml) sketch a **Container Apps + ACR + OIDC** topology so you don't start from a blank page. The meaningful design choices — SKUs, database/storage strategy, API ingress visibility, secrets, scaling — are intentionally left as `TODO`s. It removes boilerplate; it does **not** do the challenge for you. Use it, extend it, or replace it. See [`infra/README.md`](../infra/README.md). +> **Starter scaffold (included in this folder).** [`infra/`](../infra/README.md) (Bicep) and [`.github/workflows/deploy.yml`](../.github/workflows/deploy.yml) sketch a **Container Apps + ACR + OIDC** topology so you don't start from a blank page. The Bicep compiles and validates as is. `deploy.yml` is a **scaffold you complete**: it only runs on manual dispatch, and its build, provision, and deploy steps are `TODO` placeholders that only print a message. The meaningful design choices (SKUs, database/storage strategy, API ingress visibility, secrets, scaling, image build order) are intentionally left as `TODO`s. Use it, extend it, or replace it. See [`infra/README.md`](../infra/README.md). +> +> Three facts that save time: build the API image with `src` as the build context (`docker build -f src/api-ts/Dockerfile src`), because it needs the shared `src/database` files. Set `namePrefix` to something unique, because the ACR name must be globally unique. The browser calls the API directly, so the API needs external ingress (the Bicep already wires this). ## Success criteria * Azure infrastructure is defined as code and provisions cleanly (no manual portal clicking to create resources). * A single GitHub Actions workflow builds, tests, provisions, and deploys the application. * Authentication to Azure uses secrets/OIDC — no credentials in source. -* The deployed application is reachable and functional in Azure (exercise a real flow, e.g. the cart). +* The deployed application is reachable and functional in Azure (exercise a real flow, e.g. browse the products, or the cart if your team built it). + +## No-Azure path + +Use this when your team has only GitHub Copilot licenses and no Azure subscription. + +* With Copilot, complete `deploy.yml` (or your own workflow) so it has a **build and test job** that runs `make install`, `make build`, and `make test-ts` (or your API track) on every push, plus the Azure provision and deploy steps. The `Makefile` is in `src`, so give that job `working-directory: 03-Azure/01-04-AI/01_Agentic_SDLC/src`. +* Guard the Azure steps so they only run when Azure is configured, for example `if: ${{ vars.AZURE_RESOURCE_GROUP != '' }}`. +* Push and confirm the build and test job runs green in the **Actions** tab. +* Confirm the IaC compiles: `az bicep build --file infra/main.bicep` (works offline in the Codespace). +* Ask Copilot to review the IaC and workflow against the [Azure Well-Architected Framework](https://learn.microsoft.com/en-us/azure/well-architected/) and fix one finding. + +Success for the no-Azure path: a green CI run, a compiling template, and a workflow that would deploy once the `AZURE_*` secrets and variables exist. ## Learning resources @@ -29,4 +54,4 @@ Deploy the full Octocat Supply application to **Microsoft Azure** using **Infras * [Authenticate to Azure from GitHub Actions using OIDC](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure-openid-connect) * [Bicep documentation](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/) * [Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/) -* [Azure Well-Architected Framework](https://learn.microsoft.com/en-us/azure/well-architected/) +* [Azure Well-Architected Framework](https://learn.microsoft.com/en-us/azure/well-architected/) \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-06.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-06.md index 0ae866ec9..531ec543c 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-06.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-06.md @@ -6,7 +6,14 @@ Use agents to monitor the deployed Octocat Supply application and improve its reliability, leveraging the **Azure SRE Agent**. Now that the app is deployed, the team wants agentic monitoring — detect, diagnose, and help remediate issues. -> This challenge depends on a reachable deployment from Challenge 5. If your team doesn't have one, pair with another team or use a shared reference deployment so you can still practise the loop. +## Before you start + +* A **reachable deployment** from Challenge 5. If your team doesn't have one, pair with another team or use a shared reference deployment so you can still practise the loop. +* Permission to create an Azure SRE Agent: **Owner**, or **Contributor** plus **User Access Administrator**, on the subscription or resource group where the agent lives. To let the agent read your app's resource group you also need **Owner** or **User Access Administrator** there. +* A region where Azure SRE Agent is offered (on the MicroHack platform, the **AzureRegion** in your lab credentials is one), and browser access to `https://sre.azure.com` and `*.azuresre.ai`. Create the agent at [sre.azure.com](https://sre.azure.com) in your lab resource group and keep the default **Model provider**. Then select **Set up your agent** > **Azure resources** > **Resource group**, pick your app's resource group and keep the default **Reader** permission level (read-only: the agent diagnoses, your team applies the fix). +* SRE Agent has an always-on charge after the evaluation period. Delete the agent when the event is over. + +> **No Azure subscription or no SRE Agent access?** This challenge is optional. Instead, run the same detect, diagnose, remediate loop locally with **Copilot Chat in agent mode**: add a `/health` endpoint to your API, break something on purpose (for example rename `src/database/migrations` or stop the API), let the agent read the logs and test output to find the root cause, fix it, and confirm `/health` and `make test-e2e` are green again. Record what the agent found versus what you found yourself. ## Actions @@ -28,5 +35,6 @@ Use agents to monitor the deployed Octocat Supply application and improve its re ## Learning resources * [Azure SRE Agent documentation](https://learn.microsoft.com/en-us/azure/sre-agent/) +* [Create and set up Azure SRE Agent](https://learn.microsoft.com/en-us/azure/sre-agent/create-and-set-up) * [Azure Monitor overview](https://learn.microsoft.com/en-us/azure/azure-monitor/overview) * [Health probes in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/health-probes) diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-07.md b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-07.md index 7288a4ce7..d805d94a6 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-07.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/challenges/challenge-07.md @@ -8,11 +8,13 @@ Implement **GitHub Agentic Workflows** to help maintain the Octocat Supply appli ## Actions -* **Identify maintenance tasks** — Choose a recurring task that benefits from automation (e.g. issue triage/labelling, dependency updates, test/lint on change, documentation upkeep). Start with a **low-risk** task. -* **Author an agentic workflow** — Create a GitHub Agentic Workflow that performs one of these tasks autonomously. -* **Define triggers and guardrails** — Configure when it runs (schedule, PR, issue) and constrain what it is allowed to do — least privilege. -* **Test the workflow** — Trigger it and observe the agent completing the task. -* **Review the output** — Confirm the agent's actions are correct and safe before enabling it broadly. +* **Identify maintenance tasks**: Choose a recurring task that benefits from automation (e.g. issue triage/labelling, dependency updates, test/lint on change, documentation upkeep). Start with a **low-risk** task. +* **Author an agentic workflow**: Create a GitHub Agentic Workflow that performs one of these tasks autonomously. In the Codespace terminal, install the CLI extension with `gh extension install github/gh-aw`. Start from a sample with `gh aw add-wizard githubnext/agentics/issue-triage` (or `daily-repo-status`), or write your own `.github/workflows/.md`. The Markdown file is the source; `gh aw compile` turns it into the `.lock.yml` file that GitHub Actions runs. Commit both files. +* **Define triggers and guardrails**: Configure when it runs (schedule, PR, issue) and constrain what it is allowed to do — least privilege. +* **Test the workflow**: Trigger it and observe the agent completing the task. `gh aw run ` starts a run, or open an issue if your trigger is `issues: opened`. +* **Review the output**: Confirm the agent's actions are correct and safe before enabling it broadly. + +> **Engine authentication.** With the default Copilot engine, the workflow needs either `permissions: copilot-requests: write` in its frontmatter (uses the Actions token) or a `COPILOT_GITHUB_TOKEN` repository secret (a fine-grained personal access token with the **Copilot Requests** permission). The `add-wizard` command guides you. In a Codespace, if `gh aw` reports missing permissions, run `unset GITHUB_TOKEN`, then `gh auth login --scopes repo,workflow`, and try again. ## Success criteria @@ -24,12 +26,14 @@ Implement **GitHub Agentic Workflows** to help maintain the Octocat Supply appli ### Optional stretch — package a reusable skill / slash command * Pick a repeatable flow you've done by hand (e.g. "read instructions → scaffold tests → run validation"). -* Package it as a reusable **skill or slash command** so it can be invoked in one step. +* Package it as a reusable **prompt file** (`.github/prompts/.prompt.md`, run it as `/` in Copilot Chat), a **custom agent** (`.github/agents/.agent.md`, see [`.github/agents/README.md`](../.github/agents/README.md)), or an **agent skill** (`.github/skills//SKILL.md`, see the `frontend-design` example) so it can be invoked in one step. * Invoke it against a real task and confirm it performs the steps. * Document where **human review stays mandatory** (e.g. before merging generated tests or committing changes). ## Learning resources -* [GitHub Agentic Workflows (gh-aw)](https://github.com/githubnext/gh-aw) +* [Your first agentic workflow](https://docs.github.com/en/copilot/how-tos/github-agentic-workflows/quickstart) +* [Creating GitHub Agentic Workflows](https://docs.github.com/en/copilot/how-tos/github-agentic-workflows/creating-github-agentic-workflows) +* [GitHub Agentic Workflows (gh-aw)](https://github.com/github/gh-aw) * [About GitHub Actions](https://docs.github.com/en/actions/learn-github-actions) * [Controlling permissions for GITHUB_TOKEN](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/README.md b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/README.md index f6a740971..e8265c812 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/README.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/README.md @@ -19,13 +19,16 @@ Azure **Container Apps** as the compute target: ┌──────────── Container Apps Environment ────────────┐ │ │ │ frontend (nginx) api (Node/Express) │ - │ external ingress :80 ────► ingress :3000 │ - │ proxies /api via nginx (internal OR external)│ + │ external ingress :80 external ingress │ + │ serves static files :443 -> :3000 │ │ │ └────────────────────┬───────────────────────────────┘ │ logs ▼ Log Analytics workspace + + Browser ──loads app──► frontend + Browser ──calls /api/*──► api public FQDN (https) ``` - **ACR** — stores the two images the apps pull. @@ -33,22 +36,35 @@ Azure **Container Apps** as the compute target: environment; provisioned first. - **Container Apps Environment** — the shared boundary both apps run in. Apps in the same environment can address each other by app name (service discovery). -- **`api` Container App** — target port **3000** (matches `src/api-ts/Dockerfile`, - which `EXPOSE`s 3000 and runs `npm start`). -- **`frontend` Container App** — external ingress on port **80** (matches - `src/frontend/Dockerfile`, nginx). It is configured with `API_HOST` / - `API_PORT` env vars pointing at the `api` app so nginx can reverse-proxy `/api` - (see `src/frontend/nginx.conf` + `src/frontend/entrypoint.sh`). +- **`api` Container App**: target port **3000** (matches `src/api-ts/Dockerfile`, + which `EXPOSE`s 3000 and runs `npm start`). It needs external ingress because + the browser calls it directly. +- **`frontend` Container App**: external ingress on port **80** (matches + `src/frontend/Dockerfile`, nginx). nginx only serves the static app. It does + not proxy `/api`. At start, `src/frontend/entrypoint.sh` writes + `runtime-config.js` with `API_URL = API_PROTOCOL://API_HOST[:API_PORT]`, and + the browser calls that URL. The Bicep sets `API_HOST` to the api's public FQDN, + `API_PORT` to `443`, and `API_PROTOCOL` to `https`. The api already allows CORS + from `*.azurecontainerapps.io`. ## How the Bicep maps to the two Dockerfiles -| Dockerfile | Port | Container App | Notes | -| --- | --- | --- | --- | -| `src/api-ts/Dockerfile` | `EXPOSE 3000` | `--api` | `targetPort: 3000`. Ingress internal-vs-external is a **TODO** decision. | -| `src/frontend/Dockerfile` | `EXPOSE 80` | `--frontend` | `targetPort: 80`, external. Gets `API_HOST` = the api app name and `API_PORT` = `3000`. The entrypoint also honours `API_PROTOCOL` (default `https`). | +| Dockerfile | Build context | Port | Container App | Notes | +| --- | --- | --- | --- | --- | +| `src/api-ts/Dockerfile` | `src` | `EXPOSE 3000` | `--api` | `targetPort: 3000`, external. The context is `src` (not `src/api-ts`) because the image also needs the shared SQL files in `src/database`. | +| `src/frontend/Dockerfile` | `src/frontend` | `EXPOSE 80` | `--frontend` | `targetPort: 80`, external. Gets `API_HOST` = the api FQDN, `API_PORT` = `443`, `API_PROTOCOL` = `https`. | + +Build commands, run from the folder that contains `src/` and `infra/`: -The workflow builds each image from its own context (`src/api-ts` and -`src/frontend`) and pushes to ACR; the Bicep then references those image tags. +```bash +docker build -f src/api-ts/Dockerfile -t api src +docker build -f src/frontend/Dockerfile -t frontend src/frontend +# or build in Azure without a local Docker daemon: +az acr build -r -t api: -f src/api-ts/Dockerfile src +az acr build -r -t frontend: -f src/frontend/Dockerfile src/frontend +``` + +The workflow pushes both images to ACR, and the Bicep then references those image tags. ## Files @@ -59,7 +75,13 @@ The workflow builds each image from its own context (`src/api-ts` and | `modules/loganalytics.bicep` | Log Analytics workspace (stub — retention/SKU TODO). | | `modules/containerapp-env.bicep` | Container Apps managed environment. | | `modules/containerapp.bicep` | Generic app module, reused for **both** api and frontend. | -| `main.parameters.json` | Placeholder parameter values with TODO comments. | +| `main.parameters.json` | Placeholder parameter values. Replace `` in the image references, and change `namePrefix` to something unique (see the note below). | + +> **Unique names.** The ACR name is derived as `acr` +> and must be globally unique across Azure. With the defaults every team gets +> `octocatdevacr` and only the first deploy wins. Set `namePrefix` to something +> personal, for example your GitHub handle (lowercase letters and digits, up to +> 12 characters). ## What's provided vs. deliberately left as `TODO` @@ -69,15 +91,16 @@ The workflow builds each image from its own context (`src/api-ts` and - Sensible parameters (`location`, `namePrefix`, `environmentName`, image references, `minReplicas` / `maxReplicas`) and outputs (ACR login server, frontend URL, api FQDN). -- The port mapping (api `3000`, frontend `80`) and the `API_HOST` / `API_PORT` - proxy wiring between frontend and api. +- The port mapping (api `3000`, frontend `80`) and the `API_HOST` / `API_PORT` / + `API_PROTOCOL` wiring that tells the browser where the api lives. - OIDC-based CI/CD plumbing in the workflow (no long-lived secrets). **Left as `TODO` (the decisions that make this a real deploy — do these):** - **SKUs** — ACR tier, Log Analytics retention, container CPU/memory. -- **api ingress visibility** — public (its own URL, easy debugging) vs. - internal-only (reached solely by the frontend inside the environment). +- **api ingress visibility**: public today, because the browser calls the api + directly. Internal-only is possible, but then you must add a `/api` reverse + proxy to `src/frontend/nginx.conf` and point the frontend at its own origin. - **Database / storage strategy** — the api ships with an in-container **SQLite** DB. In Container Apps that is **ephemeral** (it resets on every revision/scale event). Choose one: keep it ephemeral for a demo, mount an @@ -89,8 +112,9 @@ The workflow builds each image from its own context (`src/api-ts` and - **Env vars / secrets** — real app configuration and how it's referenced. - **Scaling rules** — replica counts are set, but add real scale triggers (HTTP concurrency, CPU, ...). -- **Service discovery** — confirm the frontend→api wiring works with whichever - ingress visibility you pick. +- **Service discovery**: confirm the frontend to api wiring works. Open the + frontend URL, open the browser dev tools, and check that `/api/products` calls + go to the api FQDN and return 200. ## Deploy it manually @@ -101,12 +125,13 @@ az bicep build --file infra/main.bicep # or: bicep build infra/main.bicep # 2. Create a resource group az group create --name --location -# 3. Deploy (fill in the image references — see main.parameters.json TODOs) +# 3. Deploy (fill in the image references and a unique namePrefix) az deployment group create \ --resource-group \ --template-file infra/main.bicep \ --parameters infra/main.parameters.json \ --parameters \ + namePrefix="" \ apiImage=".azurecr.io/api:" \ frontendImage=".azurecr.io/frontend:" @@ -130,6 +155,11 @@ by default**: the `push` trigger is commented out and it needs the OIDC secrets below. Set those up, finish the TODO steps with Copilot, then run it from the **Actions** tab (`workflow_dispatch`). +> GitHub Actions only reads workflows from `.github/workflows/` at the **root of +> the repository**. `scripts/setup-fork.sh` (run in [Challenge 1](../challenges/challenge-01.md)) +> copies this file to the root of your MicroHack fork, so edit and run that copy. Its +> `run` steps start in the hack folder (`defaults.run.working-directory`). + Required GitHub **secrets**: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_SUBSCRIPTION_ID`. Required **variables**: `AZURE_RESOURCE_GROUP`, `AZURE_LOCATION`. See the header comment in the workflow for the federated- diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.bicep b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.bicep index b75d3da04..535374550 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.bicep +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.bicep @@ -4,15 +4,17 @@ // Target architecture expressed here (Azure Container Apps): // // ACR ──images──> ┌─────────────── Container Apps Environment ───────────────┐ -// │ frontend (nginx, :80, external) ──proxy──> api (:3000) │ +// │ frontend (nginx, :80, external) api (:3000, external) │ // └───────────────────────────────────────────────────────────┘ // │ logs // Log Analytics workspace // -// The frontend's nginx proxies /api to the api app using API_HOST / API_PORT -// (see src/frontend/entrypoint.sh + nginx.conf). Within one Container Apps -// environment, apps can address each other by app name, which is what makes -// that service discovery work. +// The frontend is a static React app. nginx only serves files; it does NOT +// proxy /api. At container start, src/frontend/entrypoint.sh writes +// runtime-config.js with API_URL = API_PROTOCOL://API_HOST[:API_PORT], and the +// user's BROWSER calls that URL directly. So the api needs external ingress and +// API_HOST must be its public FQDN (port 443, https). The api already allows +// CORS from *.azurecontainerapps.io (see src/api-ts/src/index.ts). // // WHAT'S PROVIDED: the wiring, parameters, module structure, outputs. // WHAT'S LEFT TO YOU (look for // TODO): SKUs, ingress visibility for the api, @@ -72,7 +74,7 @@ var frontendAppName = '${baseName}-frontend' var commonTags = { project: 'octocat-supply' - challenge: 'challenge-4-azure-deploy' + challenge: 'challenge-5-azure-deploy' managedBy: 'bicep' environment: environmentName } @@ -118,9 +120,10 @@ module environment 'modules/containerapp-env.bicep' = { // API container app — listens on 3000. // ----------------------------------------------------------------------------- // TODO: Ingress visibility decision. `externalIngress: true` gives the api its -// own public URL (handy for debugging/tests). Set it to false to make the -// api internal-only and reachable solely by the frontend inside the env — -// usually the more correct production choice. Pick one deliberately. +// own public URL, and the browser-side frontend needs that today. To make +// the api internal-only you must first add a reverse proxy for /api to +// src/frontend/nginx.conf and point the frontend at its own origin. +// Pick one deliberately. module apiApp 'modules/containerapp.bicep' = { name: 'api-app' params: { @@ -143,10 +146,10 @@ module apiApp 'modules/containerapp.bicep' = { } // ----------------------------------------------------------------------------- -// Frontend container app — nginx on 80, external, proxying to the api. +// Frontend container app: nginx on 80, external, serving the static app. // ----------------------------------------------------------------------------- -// The API_HOST/API_PORT env vars tell nginx where the api lives. Using the api -// app name resolves inside the environment for service discovery. +// API_HOST/API_PORT/API_PROTOCOL become the API_URL the browser calls, so they +// point at the api's public FQDN on 443. module frontendApp 'modules/containerapp.bicep' = { name: 'frontend-app' params: { @@ -165,17 +168,17 @@ module frontendApp 'modules/containerapp.bicep' = { env: [ { name: 'API_HOST' - value: apiAppName + value: apiApp.outputs.fqdn } { + // Container Apps ingress serves https on 443 and forwards to port 3000. name: 'API_PORT' - // TODO: If you make the api internal-only, confirm the frontend still - // reaches it on 3000 within the environment (it should). If you - // front the api on 443/https externally, adjust API_PORT/PROTOCOL. - value: '3000' + value: '443' + } + { + name: 'API_PROTOCOL' + value: 'https' } - // TODO: The entrypoint also honours API_PROTOCOL (default https). Add it - // here if your ingress/scheme requires it. ] } } diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.parameters.json b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.parameters.json index 8b334a581..b98c26ca5 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.parameters.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/main.parameters.json @@ -2,14 +2,12 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "_comment_location": "TODO: Set a region with Container Apps capacity (e.g. eastus, westeurope). Defaults to the resource group location if omitted.", "namePrefix": { "value": "octocat" }, "environmentName": { "value": "dev" }, - "_comment_images": "TODO: Replace with your registry login server once the ACR name is known. The workflow builds/pushes these tags. On a first bootstrap you may point at a public placeholder image until the real images exist.", "apiImage": { "value": ".azurecr.io/api:latest" }, @@ -22,7 +20,6 @@ "maxReplicas": { "value": 3 }, - "_comment_registry_creds": "TODO: These enable the simplest ACR-admin-credentials path for a first deploy. Prefer a user-assigned managed identity with AcrPull and leave these empty. Never commit real values — pass them at deploy time (e.g. from the workflow) instead.", "registryUsername": { "value": "" }, @@ -30,4 +27,4 @@ "value": "" } } -} +} \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp-env.bicep b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp-env.bicep index 83334ee6a..beb021cb7 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp-env.bicep +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp-env.bicep @@ -2,8 +2,9 @@ // Module: containerapp-env.bicep (Azure Container Apps managed environment) // ----------------------------------------------------------------------------- // The shared environment both apps (api + frontend) run in. Apps in the same -// environment can reach each other by app name for service discovery — this is -// what lets the frontend's nginx proxy to the api (see API_HOST/API_PORT). +// environment can reach each other by app name for service discovery. Today the +// browser calls the api directly on its public FQDN (see main.bicep), so this +// only matters if you add a server-side proxy. // // STARTER SKELETON — compiles as-is; decisions left as // TODO. // ============================================================================= diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp.bicep b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp.bicep index bae5bab8e..99b5d9540 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp.bicep +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/infra/modules/containerapp.bicep @@ -3,8 +3,8 @@ // ----------------------------------------------------------------------------- // One reusable module for BOTH workloads: // - api: target port 3000, ingress (internal or external — a TODO decision) -// - frontend: target port 80, external ingress, with API_HOST/API_PORT env -// vars pointing at the api app so nginx can proxy /api. +// - frontend: target port 80, external ingress, with API_HOST/API_PORT/ +// API_PROTOCOL env vars that become the API URL the browser calls. // // STARTER SKELETON — compiles as-is; decisions left as // TODO. // ============================================================================= diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/README.md b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/README.md new file mode 100644 index 000000000..493c9b7e8 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/README.md @@ -0,0 +1,9 @@ +# Lab automation: Agentic SDLC + +Used by the MicroHack platform. + +- `lab-defaults.json`: every lab user gets a **GitHub Copilot seat** (`GHCPUsers`). The platform creates a GitHub organization for the event with Entra managed user accounts. +- `shared-deploy-lab.ps1`: registers the resource providers for Challenges 5 and 6 once per subscription. +- `deploy-lab.ps1`: creates an **empty resource group** per lab and makes the lab user **Owner**, because the Challenge 5 OIDC setup and the Challenge 6 Azure SRE Agent create role assignments. It returns `ResourceGroupName` and `AzureRegion` as lab credentials. + +Nothing is deployed up front. Costs come from what teams deploy in Challenges 5 and 6 (Container Apps, Basic Container Registry, Log Analytics, SRE Agent). The preferred regions are regions where Azure SRE Agent is offered. diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/deploy-lab.ps1 b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/deploy-lab.ps1 new file mode 100644 index 000000000..f94399191 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/deploy-lab.ps1 @@ -0,0 +1,62 @@ +<# +.SYNOPSIS +Prepares one Agentic SDLC lab: an empty resource group the team owns. +.DESCRIPTION +The hack deploys nothing up front. Participants deploy the app themselves in Challenge 5 +(Container Apps, Container Registry, Log Analytics) and create an Azure SRE Agent in Challenge 6. +Both create role assignments, so the lab users get Owner on the resource group. +.PARAMETER DeploymentType +Defines the deployment scope; allowed values are subscription, resourcegroup, or resourcegroup-with-subscriptionowner. +.PARAMETER SubscriptionId +Specifies the Azure subscription that contains the lab resources. +.PARAMETER ResourceGroupName +For resource group deployment, specifies the target resource group name. +.PARAMETER PreferredLocation +Specifies the preferred Azure regions, ordered by preference. The defaults are regions where Azure SRE Agent is offered. +.PARAMETER AllowedEntraUserIds +Entra user object IDs of the lab users. +#> +param( + [Parameter(Mandatory=$true)] + [ValidateSet('subscription','resourcegroup', 'resourcegroup-with-subscriptionowner')] + [string]$DeploymentType, + + [Parameter(Mandatory=$true)] + [string]$SubscriptionId, + + [string]$ResourceGroupName = "", + + [string[]]$PreferredLocation = @(), + + [string[]]$AllowedEntraUserIds = @() +) + +if($DeploymentType -ne 'subscription' -and [string]::IsNullOrEmpty($ResourceGroupName)) { + throw "ResourceGroupName must be provided when DeploymentType is '$DeploymentType'." +} + +$effectiveLocation = if($PreferredLocation.Count -gt 0) { $PreferredLocation[0] } else { "swedencentral" } + +if($DeploymentType -eq 'subscription') { + $effectiveResourceGroup = "rg-agentic-sdlc-$(Get-MhhStablehash $AllowedEntraUserIds -Length 12)" +} else { + $effectiveResourceGroup = $ResourceGroupName +} + +$rg = Get-AzResourceGroup -Name $effectiveResourceGroup -ErrorAction SilentlyContinue +if(-not $rg) { + Write-Host "Creating resource group '$effectiveResourceGroup' in '$effectiveLocation'..." + $rg = New-AzResourceGroup -Name $effectiveResourceGroup -Location $effectiveLocation -Tag @{ microhack = "01_Agentic_SDLC" } +} + +foreach($userId in $AllowedEntraUserIds) { + if([string]::IsNullOrWhiteSpace($userId)) { continue } + $existing = Get-AzRoleAssignment -ObjectId $userId -RoleDefinitionName "Owner" -Scope $rg.ResourceId -ErrorAction SilentlyContinue + if(-not $existing) { + Write-Host "Granting Owner on '$effectiveResourceGroup' to $userId..." + New-AzRoleAssignment -ObjectId $userId -RoleDefinitionName "Owner" -Scope $rg.ResourceId -ErrorAction Stop | Out-Null + } +} + +@{"HackboxCredential" = @{ name = "ResourceGroupName"; value = $effectiveResourceGroup; note = "Resource group for Challenge 5 (deploy) and Challenge 6 (Azure SRE Agent). You are Owner." }} +@{"HackboxCredential" = @{ name = "AzureRegion"; value = $rg.Location; note = "Region for the deployment and the SRE Agent." }} diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/lab-defaults.json b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/lab-defaults.json new file mode 100644 index 000000000..2c31030f5 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/lab-defaults.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/MicroHack/refs/heads/main/lab-defaults-schema.json", + "groups": ["GHCPUsers"], + "deploymentType": "resourcegroup-with-subscriptionowner", + "labsPerSubscription": 10, + "preferredLocation": "swedencentral, francecentral, uksouth", + "estimatedDailyCostsUsd": 10.0, + "estimatedSharedDeploymentDailyCostsUsd": 0.0, + "Quality": "Testing" +} \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/shared-deploy-lab.ps1 b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/shared-deploy-lab.ps1 new file mode 100644 index 000000000..17a249f3c --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/labautomation/shared-deploy-lab.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS +Runs once per subscription before deploy-lab.ps1: registers the resource providers the hack needs. +#> +param( + [Parameter(Mandatory=$true)] + [string]$SubscriptionId, + + [Parameter(Mandatory=$true)] + [string[]]$PreferredLocation = @(), + + [Parameter(Mandatory=$false)] + [string[]]$AllowedEntraUserIds = @() +) + +$requiredProviders = @( + "Microsoft.App", + "Microsoft.ContainerRegistry", + "Microsoft.OperationalInsights", + "Microsoft.Insights", + "Microsoft.ManagedIdentity", + "Microsoft.AlertsManagement" +) + +foreach($provider in $requiredProviders) { + $state = (Get-AzResourceProvider -ProviderNamespace $provider -ErrorAction Stop | Select-Object -First 1).RegistrationState + if($state -eq "Registered") { + Write-Host "[$SubscriptionId] Resource provider $provider is already registered." + continue + } + Write-Host "[$SubscriptionId] Registering resource provider: $provider" + Register-AzResourceProvider -ProviderNamespace $provider -ErrorAction Stop | Out-Null +} diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/README.md b/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/README.md index fbb1f4ba6..5a3094921 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/README.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/README.md @@ -2,6 +2,20 @@ Utility scripts for running the Agentic SDLC Hackathon. +## `setup-fork.sh`: prepare your MicroHack fork (Challenge 1) + +Run once in the Codespace terminal after you fork `microhack` in the event organization: + +```bash +bash scripts/setup-fork.sh +``` + +It points the GitHub CLI at your fork, checks that Issues are on (turn them on in the fork settings first), copies this hack's +`.github/` Copilot files (instructions, custom agents, skills) and workflows to the root of the +fork (the Copilot cloud agent, Copilot code review and GitHub Actions only read the repository +root), removes the MicroHack PR compliance workflows from the fork, then commits and pushes. +Run it again after you change anything under this hack's `.github/` folder. + ## `seed-backlog.sh` / `seed-backlog.ps1` — Seed the Challenge 3 backlog These scripts create the [Challenge 3 backlog](../assets/backlog.md) as real **GitHub Issues** in a @@ -58,12 +72,11 @@ any changes. ./scripts/seed-backlog.ps1 -DryRun ``` -> On macOS/Linux you may need to make the script executable first: `chmod +x scripts/seed-backlog.sh`. +> On macOS/Linux you may need to make the script executable first: `chmod +x scripts/seed-backlog.sh`, or run it with `bash scripts/seed-backlog.sh`. ### When to run it (event flow) -- **Pre-event, per team repo/fork.** As part of pre-event repo prep, run the seeder against each team's repo/fork so the backlog is already there - when teams reach Challenge 3. +- **In Challenge 1, per participant repo.** Each participant runs `bash scripts/seed-backlog.sh` in their own Codespace so the backlog is there when they reach Challenge 3. Coaches who prepare repos for teams can run it before the event with `--repo `. - **Do a `--dry-run` first** to confirm the target repo and see the list before creating anything. - It's safe to re-run if a repo was missed or you want to top up after manual edits — duplicates are skipped by title. diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/setup-fork.sh b/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/setup-fork.sh new file mode 100755 index 000000000..6fb30ea11 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/scripts/setup-fork.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# setup-fork.sh - Prepare your fork of the MicroHack repository for the Agentic SDLC hack. +# +# Run once in the Codespace terminal (Challenge 1): +# bash scripts/setup-fork.sh +# +# What it does: +# 1. Points the GitHub CLI at your fork (not the repository you forked from). +# 2. Checks that Issues are on in the fork (forks start with Issues off; turn them on in Settings). +# 3. Copies this hack's Copilot files (.github/copilot-instructions.md, instructions, +# agents, skills) and workflows to the root .github/ folder of the fork. The Copilot +# cloud agent, Copilot code review and GitHub Actions only read the repository root. +# 4. Removes the MicroHack PR compliance workflows from the fork, so they do not run on +# your pull requests. +# 5. Commits and pushes the result. +# Safe to run again. +set -euo pipefail + +HACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +ROOT="$(git -C "$HACK_DIR" rev-parse --show-toplevel)" +REL="${HACK_DIR#"$ROOT"/}" + +if [[ "$ROOT" == "$HACK_DIR" ]]; then + echo "This hack is already the repository root. Nothing to copy." + exit 0 +fi + +ORIGIN="$(git -C "$ROOT" remote get-url origin)" +REPO="$(echo "$ORIGIN" | sed -E 's#(\.git)?/?$##; s#.*github\.com[:/]##')" +echo "Fork: $REPO" +echo "Hack folder: $REL" + +if ! gh auth status >/dev/null 2>&1; then + echo "The GitHub CLI is not signed in. Run: gh auth login (GitHub.com, HTTPS, browser, lab account)" + echo "Then run this script again." + exit 1 +fi + +gh repo set-default "$REPO" + +# A Codespace token cannot change repository settings, so only check them here. +if [[ "$(gh api "repos/$REPO" --jq .has_issues 2>/dev/null)" != "true" ]]; then + echo "Issues are off in your fork. On github.com open your fork > Settings > General > Features," + echo "tick Issues, then run this script again." + exit 1 +fi +echo "Issues: on. Actions: open the Actions tab of your fork once and enable workflows if GitHub asks." +echo "Copying Copilot files and workflows to the repository root..." +mkdir -p "$ROOT/.github" +for item in copilot-instructions.md instructions agents skills workflows; do + [[ -e "$HACK_DIR/.github/$item" ]] && cp -r "$HACK_DIR/.github/$item" "$ROOT/.github/" +done + +# Path-specific instructions use paths relative to the hack folder; make them repo-relative. +for f in "$ROOT"/.github/instructions/*.instructions.md; do + [[ -f "$f" ]] || continue + sed -i -E "/^applyTo:/ s#(\"|, )src/#\1$REL/src/#g" "$f" +done + +NOTE="> This repository is a fork of MicroHack. The Octocat Supply app lives in \`$REL/\`; all paths below are relative to that folder. Run build and test commands from \`$REL/src\`." +if ! grep -qF "$NOTE" "$ROOT/.github/copilot-instructions.md"; then + printf '%s\n\n%s' "$NOTE" "$(cat "$ROOT/.github/copilot-instructions.md")" > "$ROOT/.github/copilot-instructions.md" +fi + +rm -f "$ROOT/.github/workflows/pr-compliance-check.yml" "$ROOT/.github/workflows/pr-compliance-comment.yml" + +cd "$ROOT" +git add -A .github +if git diff --cached --quiet; then + echo "Already set up. Nothing to commit." +else + git commit -q -m "Set up the Agentic SDLC hack at the repository root" + git push -q + echo "Pushed the root .github/ setup to $REPO." +fi +echo "Done." diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/.dockerignore b/03-Azure/01-04-AI/01_Agentic_SDLC/src/.dockerignore new file mode 100644 index 000000000..3ce79a130 --- /dev/null +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/.dockerignore @@ -0,0 +1,16 @@ +# Used when building src/api-ts/Dockerfile with src/ as the build context. +**/node_modules +**/dist +**/data +**/coverage +**/bin +**/obj +**/.venv +**/target +**/*.db +frontend +api-cs +api-cs-tests +api-py +api-java +docs \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/Makefile b/03-Azure/01-04-AI/01_Agentic_SDLC/src/Makefile index 8a613e99e..4e4ee0436 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/Makefile +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/Makefile @@ -218,7 +218,7 @@ install-playwright-browsers: ## Install Playwright browser binaries used by fron echo "Playwright Chromium already installed, skipping."; \ else \ $(MKDIR_P) "$(PLAYWRIGHT_BROWSERS_PATH)"; \ - cd $(FRONTEND_DIR) && PLAYWRIGHT_BROWSERS_PATH="$(PLAYWRIGHT_BROWSERS_PATH)" npx playwright install chromium; \ + cd $(FRONTEND_DIR) && PLAYWRIGHT_BROWSERS_PATH="$(PLAYWRIGHT_BROWSERS_PATH)" npx playwright install --with-deps chromium; \ fi .PHONY: test-frontend diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/README.md b/03-Azure/01-04-AI/01_Agentic_SDLC/src/README.md index d4fec9f54..91ac89e38 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/README.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/README.md @@ -15,7 +15,7 @@ Express.js TypeScript backend API server (port **3000**) ASP.NET Core .NET 10 backend API server (port **3000**) - Port of the TypeScript API using C# records, repositories, and controllers - Microsoft.Data.Sqlite with shared migration SQL -- Swashbuckle OpenAPI/Swagger documentation +- OpenAPI document via Microsoft.AspNetCore.OpenApi (`/api-docs.json`) ### `/api-cs-tests` C# test project for the .NET API @@ -95,6 +95,15 @@ make test-ts make test-cs make test-py make test-java + +# Frontend end-to-end tests (Playwright, Chromium) +make test-e2e + +# TypeScript API + frontend tests together +make test + +# Lint the TypeScript API and frontend +make lint ``` ## API Variants — Port Reference @@ -109,13 +118,13 @@ make test-java All API variants expose the same REST endpoints and connect to a SQLite database at `./data/app.db` by default. Override with the `DB_FILE` environment variable. -Swagger/OpenAPI docs are available at `/api-docs` for each running API. +OpenAPI docs: Swagger UI at `/api-docs` (TypeScript, Java) or `/docs` (Python). The OpenAPI JSON is at `/api-docs.json` (TypeScript, C#, Java) or `/openapi.json` (Python). ## Technology Stack - **TypeScript API**: Node.js, Express.js, better-sqlite3 -- **C# API**: .NET 10, ASP.NET Core, Microsoft.Data.Sqlite, Swashbuckle +- **C# API**: .NET 10, ASP.NET Core, Microsoft.Data.Sqlite, Microsoft.AspNetCore.OpenApi - **Python API**: Python 3.11+, FastAPI, aiosqlite, Pydantic v2 -- **Java API**: Java 21, Spring Boot 3, sqlite-jdbc, SpringDoc OpenAPI +- **Java API**: Java 17, Spring Boot 3, sqlite-jdbc, SpringDoc OpenAPI - **Frontend**: React 18, Vite, Tailwind CSS, Playwright (E2E) - **Database**: SQLite (shared schema in `/database`) diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-cs-tests/Repositories/SuppliersRepositoryTests.cs b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-cs-tests/Repositories/SuppliersRepositoryTests.cs index c96f9fc24..dc41d4f29 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-cs-tests/Repositories/SuppliersRepositoryTests.cs +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-cs-tests/Repositories/SuppliersRepositoryTests.cs @@ -1,3 +1,4 @@ +using Microsoft.Data.Sqlite; using Microsoft.Extensions.Logging.Abstractions; using OctoSupply.Api.Data; using OctoSupply.Api.Models; @@ -42,6 +43,8 @@ public async Task CreateAndFindById_PersistsSupplier() finally { Environment.SetEnvironmentVariable("DB_FILE", null); + // Release pooled handles so the file can be deleted on Windows. + SqliteConnection.ClearAllPools(); if (File.Exists(dbPath)) { File.Delete(dbPath); @@ -68,6 +71,8 @@ public async Task Update_WithNoFields_ThrowsValidationException() finally { Environment.SetEnvironmentVariable("DB_FILE", null); + // Release pooled handles so the file can be deleted on Windows. + SqliteConnection.ClearAllPools(); if (File.Exists(dbPath)) { File.Delete(dbPath); diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/Dockerfile b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/Dockerfile index 485db78c4..3a1dde803 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/Dockerfile +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/Dockerfile @@ -1,17 +1,21 @@ +# Build context is src/ (not src/api-ts) so the shared SQL files in src/database +# are available. From the src/ folder run: +# docker build -f api-ts/Dockerfile -t octocat-api . FROM node:24-alpine AS builder WORKDIR /app -COPY ./package*.json ./ +COPY api-ts/package*.json ./ RUN npm install -COPY . . +COPY api-ts/ . RUN npm run build FROM node:24-alpine WORKDIR /app -COPY ./package*.json ./ +COPY api-ts/package*.json ./ RUN npm install --omit=dev COPY --from=builder /app/dist ./dist -COPY --from=builder /app/database ./database +# The API resolves migrations and seed data from ../database (relative to /app). +COPY database /database EXPOSE 3000 -CMD ["npm", "start"] +CMD ["npm", "start"] \ No newline at end of file diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/package.json b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/package.json index f7887154e..c0aebdbe0 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/package.json +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/package.json @@ -7,7 +7,8 @@ "start": "npm run start:install", "start:install": "npm run db:seed && node dist/index.js", "dev": "npm run db:seed:dev && tsx src/index.ts", - "test": "vitest", + "test": "vitest run", + "test:watch": "vitest", "test:coverage": "vitest run --coverage", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/src/generate-swagger.ts b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/src/generate-swagger.ts index 3a968bf1d..c85269826 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/src/generate-swagger.ts +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/src/api-ts/src/generate-swagger.ts @@ -23,5 +23,5 @@ const swaggerOptions = { const swaggerSpec = swaggerJsdoc(swaggerOptions); const outputPath = resolve(__dirname, '..', 'api-swagger.json'); -writeFileSync(outputPath, JSON.stringify(swaggerSpec, null, 4) + '\n'); +writeFileSync(outputPath, `${JSON.stringify(swaggerSpec, null, 4)}\n`); console.log(`Swagger spec written to ${outputPath}`); diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-01/solution-01.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-01/solution-01.md index 71ddd8b08..432e2be2b 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-01/solution-01.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-01/solution-01.md @@ -14,14 +14,15 @@ The aim here is a smooth, fast start — a good setup means the rest of the day ### Task 1: Get the code and open an environment -- Open your team's copy of this MicroHack in **GitHub Codespaces** (fastest, nothing to install), a local **VS Code Dev Container**, or locally. +- Sign in with the lab account, fork the `microhack` repository in the event organization (name it `microhack-`), and create the Codespace with **New with options** > **Azure / AI / Agentic SDLC**. The default configuration does not have the tools this hack needs. +- 💡 The first Codespace start runs `make install` and `make build` and takes about 5 to 10 minutes. Use that time to read `src/README.md`. - 💡 If local setup takes more than ~15 minutes, **switch to Codespaces** rather than fighting a local toolchain. -- Confirm you're on the intended working branch. +- Turn on Issues and Actions in the fork (Settings and the Actions tab), then run `bash scripts/setup-fork.sh` once (checks Issues and creates the root `.github/` copy for the cloud agent, code review and workflows), then `bash scripts/seed-backlog.sh` so the Challenge 3 backlog exists as Issues in the fork. ### Task 2: Verify runtimes and enable Copilot - In Codespaces / the Dev Container, Node.js 24, Python 3.13, .NET 10, and Java 17 are preinstalled. Locally, install only the runtime for your chosen API track plus Node.js. -- Sign in to GitHub Copilot in the IDE. **Proof that it works** is a real Chat response about a file you have open — not just the extension being installed. If suggestions are empty, sign out/in, confirm your seat is assigned, and open a real source file so the agent has context. +- Sign in to GitHub Copilot in the IDE. **Proof that it works** is a real answer in the **Chat** view in **Agent** mode about a file you have open, not just the extension being installed. If the Chat view is empty or says you have no access, sign out and in, confirm your Copilot license is assigned to this GitHub account, and open a real source file so the agent has context. ### Task 3: Explore the repo @@ -30,12 +31,12 @@ The aim here is a smooth, fast start — a good setup means the rest of the day ### Task 4: Run the app locally -- Start the frontend and one API (see `src/README.md` — `make dev` / per-variant targets). Load a page in the browser and confirm the API responds. +- Start the frontend and one API: `cd src && make dev` (TypeScript API on 3000, frontend on 5137), or `make dev-cs`, `make dev-py`, `make dev-java` for the other tracks. Open port 5137 from the **Ports** tab and check that the Products page lists products. If it is empty in a Codespace, set port 3000 to **Public**. - Pick the API language your team is most comfortable with; the choice doesn't affect the concepts in later challenges. ## Optional stretch — repo-wide agent context -Create an `AGENTS.md` and/or `.github/copilot-instructions.md` with: +Create an `AGENTS.md` and/or extend the existing `.github/copilot-instructions.md` with: - **Conventions** — concrete, repo-specific rules (naming, repository pattern, DTO/type usage), not generic advice. - **Validation commands** — the exact build/test commands for your track and the frontend. - **Scope rules** — explicit "do not touch" boundaries (generated files, infra, unrelated services). diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-02/solution-02.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-02/solution-02.md index 24f21f84a..61001225a 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-02/solution-02.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-02/solution-02.md @@ -25,6 +25,7 @@ Validate end to end ~4 min ### Task 1: Understand what already exists - Ask Copilot to explain the existing cart-related code in the frontend and API and to point out what's missing. Note the repo patterns you must follow: repository pattern, DTOs/types, error handling, consistent HTTP status codes (see `.github/instructions/api.instructions.md`). +- What teams usually find: the only cart code is `handleAddToCart` in `src/frontend/src/components/entity/product/Products.tsx` (a `TODO` plus an `alert`) and a "My Cart" link in the footer. No API variant has cart endpoints, and the schema in `src/database/migrations/` has no cart table yet. A new migration file there is shared by all four APIs. ### Task 2: Design the behaviours first diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-03/solution-03.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-03/solution-03.md index e3d1b7559..0d0dd4040 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-03/solution-03.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-03/solution-03.md @@ -6,7 +6,7 @@ Duration: 60 minutes ## Prerequisites -Complete [Challenge 2](../challenge-02/solution-02.md). If the backlog has been seeded as GitHub Issues, have the Issues tab open. +Complete [Challenge 2](../challenge-02/solution-02.md). Have the Issues tab with the backlog you seeded in Challenge 1 open. ## Approach @@ -24,7 +24,7 @@ Agent-assisted review ~8 min ### Task 1: Choose a backlog item -- Pick one from `assets/backlog.md` — payment integration for the cart, order history, product search/filtering, or inventory management are good candidates. If seeded as Issues, pick a real labelled issue. +- Pick one from `assets/backlog.md`. Payment integration for the cart, order history, product search/filtering, or inventory management are good candidates. Pick the matching labelled issue you seeded in Challenge 1. Note that the Products page already has a basic name search, so search/filtering means extending it (for example filters by supplier or price). ### Task 2: Plan with the agent first @@ -45,8 +45,8 @@ Agent-assisted review ~8 min ## Optional stretch — harnesses, MCP & requirement refinement -- **Compare harnesses** — run the planning step in Copilot CLI vs. the Copilot App / IDE chat; write a decision rule for quick fix vs. multi-file change. -- **Wire in an MCP server** — connect the GitHub MCP server to pull real backlog context (issues, PRs); note what stays local-only vs. what the server can see. +- **Compare harnesses**: run the planning step in GitHub Copilot CLI (`npm install -g @github/copilot`, then `copilot`) vs. VS Code Copilot Chat in agent mode; write a decision rule for quick fix vs. multi-file change. A good third data point: assign the issue to **Copilot** on github.com (Copilot cloud agent) and compare its pull request with your local result. +- **Wire in an MCP server**: start the preconfigured `github-remote` server in `.vscode/mcp.json` to pull real backlog context (issues, PRs); note what stays local-only vs. what the server can see. - **Refine a requirement from WorkIQ signal** — point the agent at `assets/workiq/` (Teams thread, support-ticket digest, stakeholder email). Synthesize across the artifacts, **separate a genuinely-new need from noise and from work already on the backlog**, and shape it into an issue-ready requirement: problem statement → acceptance criteria → scoped tasks (optionally a GitHub Issue). There is deliberately **no answer key** — realistic noise is mixed in, and the skill being assessed is the refinement, not guessing a specific feature. A good refinement has a clear problem statement, testable acceptance criteria, timebox-sized scope, and evidence the new need was separated from backlog/noise. The **Requirement Refiner** custom agent (`.github/agents/`) can guide this and will not name a "correct" feature. ## Common blockers diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-04/solution-04.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-04/solution-04.md index d31bd09c9..920bcdbf1 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-04/solution-04.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-04/solution-04.md @@ -24,7 +24,7 @@ Fix findings ~3 min ### Task 1: Establish a green baseline -- Run the existing API and frontend suites and confirm they pass. If the baseline fails on a clean checkout, it's usually an environment issue from Challenge 1 — fix that first (Codespaces), then re-run. +- Run the existing API and frontend suites and confirm they pass. The exact commands are in the [Challenge 4 test commands table](../../challenges/challenge-04.md#test-commands). A clean checkout is green: `make test-ts` (18 tests), `make test-cs` (2), `make test-py` (1), `make test-java` (5), and `make test-e2e` (3). If the baseline fails, it's usually an environment issue from Challenge 1. Common ones: Playwright browser libraries missing (run `make test-e2e`, which installs them), or port 3000 not **Public** in a Codespace. Fix that first, then re-run. ### Task 2: Find the gaps @@ -38,8 +38,9 @@ Fix findings ~3 min ### Task 4: Agent-assisted review -- Run the code review agent (or Copilot review) on your recent changes. +- Ask Copilot Chat in agent mode to review your diff, or open a pull request and request **Copilot** as a reviewer (Copilot code review). Both read the repo instructions in `.github/`. - Triage findings by the escalation order: **security / data integrity → correctness → performance → maintainability → style.** Fix the top; note the rest. Don't drown in nits. +- Coach hint: the TypeScript API contains planted security issues for the review to find, for example a command injection in the `PUT /api/deliveries/:id/status` route (`src/api-ts/src/routes/delivery.ts`) and a committed sample private key (`src/api-ts/ca.key`). They are intentional challenge content. Teams fix them in their own copy; do not remove them from the MicroHack source. ### Task 5: Fix findings diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-05/solution-05.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-05/solution-05.md index f84186488..c270ccd09 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-05/solution-05.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-05/solution-05.md @@ -6,7 +6,7 @@ Duration: 60 minutes ## Prerequisites -Complete [Challenge 4](../challenge-04/solution-04.md). Confirm your **Azure prerequisites**: subscription/budget, Contributor on your scope, a working GitHub ↔ Azure **OIDC federated credential**, and region capacity. +Complete [Challenge 4](../challenge-04/solution-04.md). Confirm your **Azure prerequisites**: subscription/budget, **Owner** (or Contributor plus User Access Administrator) on your resource group, a working GitHub ↔ Azure **OIDC federated credential**, and region capacity. No Azure? Use the [no-Azure path](../../challenges/challenge-05.md#no-azure-path) and aim for a green CI run plus a compiling template. ## Approach @@ -24,7 +24,9 @@ Deploy and verify ~10 min ### Task 1: Choose IaC and author templates - Pick **Bicep** or **Terraform** and let Copilot scaffold the resources: compute for frontend/API, storage/database, supporting services. -- 💡 **Optional starter scaffold** — [`infra/`](../../infra/README.md) (Bicep) is bundled in this MicroHack folder; combined with the bundled [`.github/workflows/deploy.yml`](../../.github/workflows/deploy.yml) it sketches a **Container Apps + ACR + Log Analytics + OIDC** topology — two apps (`api` on port 3000, `frontend`/nginx on port 80). The design decisions (SKUs, database/storage strategy, API ingress visibility, secrets, scaling, image build/push, frontend→api discovery) are deliberately left as `TODO`. It's a de-risking starting point, **not** a required or "correct" answer — extend it, replace it, or ignore it. See [`infra/README.md`](../../infra/README.md). +- 💡 **Optional starter scaffold**: [`infra/`](../../infra/README.md) (Bicep) is bundled in this MicroHack folder; combined with the bundled [`.github/workflows/deploy.yml`](../../.github/workflows/deploy.yml) it sketches a **Container Apps + ACR + Log Analytics + OIDC** topology with two apps (`api` on port 3000, `frontend`/nginx on port 80). The design decisions (SKUs, database/storage strategy, API ingress visibility, secrets, scaling, image build/push order) are deliberately left as `TODO`. The workflow steps after `azure/login` only print `TODO` until you complete them. It's a de-risking starting point, **not** a required or "correct" answer. Extend it, replace it, or ignore it. See [`infra/README.md`](../../infra/README.md). +- 🔑 Three traps that cost teams time: (1) the API image must be built with `src` as the context (`docker build -f src/api-ts/Dockerfile src` or `az acr build ... -f src/api-ts/Dockerfile src`) because it copies `src/database`; (2) the ACR name `acr` is global, so set a unique `namePrefix`; (3) the browser calls the API directly (nginx does not proxy `/api`), so the API keeps external ingress and the frontend gets the API FQDN on 443. The Bicep already wires (3). +- First deploy ordering: the images live in the ACR that the template creates. The simplest order is to create the ACR first (`az acr create` with the same name the Bicep derives), push both images with `az acr build`, then deploy `main.bicep`. A public placeholder image also works for a first pass, but it listens on a different port, so expect an unhealthy revision until the real images are in place. ### Task 2: Build one linear pipeline @@ -32,11 +34,11 @@ Deploy and verify ~10 min ### Task 3: Configure secure auth -- 🔑 Use **OIDC federated credentials** (with User-Assigned Managed Identity) for Azure auth, not long-lived secrets. The **most common wall** is the federated-credential subject (`repo:/:ref:refs/heads/main` or an environment subject) or a missing role. If auth fails in the pipeline, check this first and confirm the identity has Contributor on your scope. Note that [`setup-oidc.sh`](../../scripts/setup-oidc.sh) is bundled in `scripts/` to help with this configuration. +- 🔑 Use **OIDC federated credentials** (with User-Assigned Managed Identity) for Azure auth, not long-lived secrets. The **most common wall** is the federated-credential subject (`repo:/:ref:refs/heads/main` or an environment subject) or a missing role. If auth fails in the pipeline, check this first and confirm the identity has Contributor on your scope. [`setup-oidc.sh`](../../scripts/setup-oidc.sh) is bundled in `scripts/` to do this setup: in the Codespace run `az login --use-device-code`, then `bash scripts/setup-oidc.sh -g -l `. Creating the role assignment needs Owner or User Access Administrator on the resource group. ### Task 4: Deploy and verify -- Get a simple deploy reachable first, then refine SKUs and structure. Load the app's Azure URL and exercise a real flow (e.g. the cart). Ask Copilot for **Azure Well-Architected** guidance when choosing SKUs/services. +- Get a simple deploy reachable first, then refine SKUs and structure. Load the app's Azure URL and exercise a real flow (e.g. browse the products, or the cart if the team built it; the starter app's cart is a `TODO` stub). Ask Copilot for **Azure Well-Architected** guidance when choosing SKUs/services. ## Common blockers diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-06/solution-06.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-06/solution-06.md index ae49fde40..65d578959 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-06/solution-06.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-06/solution-06.md @@ -6,7 +6,7 @@ Duration: 30 minutes ## Prerequisites -Complete [Challenge 5](../challenge-05/solution-05.md) — you need a **reachable deployment**. No deploy? Pair with another team or use a shared reference environment so you can still practise the loop. Confirm the **Azure SRE Agent** is available in your region/subscription and accessible to you. +Complete [Challenge 5](../challenge-05/solution-05.md). You need a **reachable deployment**. No deploy? Pair with another team or use a shared reference environment so you can still practise the loop. Confirm the **Azure SRE Agent** is available in your region/subscription and that you have **Owner** (or Contributor plus User Access Administrator) to create it at [sre.azure.com](https://sre.azure.com). No Azure at all? Run the local loop described in [Challenge 6](../../challenges/challenge-06.md) with Copilot Chat in agent mode. ## Approach @@ -28,7 +28,7 @@ Remediate + confirm healthy ~4 min ### Task 2: Connect the SRE Agent -- Connect the Azure SRE Agent to the **correct deployed resources / resource group** so it can observe application health and report status. Permissions errors usually mean the agent needs extra roles on the monitored resources. +- Connect the Azure SRE Agent to the **correct deployed resources / resource group** so it can observe application health and report status. In the SRE Agent portal this is **Set up your agent** > **Azure resources** > **Resource group**. The default **Reader** level grants Reader, Monitoring Reader, Log Analytics Reader and Container Apps Operator, which is enough to diagnose. Permissions errors usually mean the agent needs extra roles on the monitored resources. ### Task 3: Simulate a clear fault diff --git a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-07/solution-07.md b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-07/solution-07.md index 675aa22cd..a28f83d77 100644 --- a/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-07/solution-07.md +++ b/03-Azure/01-04-AI/01_Agentic_SDLC/walkthrough/challenge-07/solution-07.md @@ -6,7 +6,7 @@ Duration: 30 minutes ## Prerequisites -Complete [Challenge 6](../challenge-06/solution-06.md). Confirm agentic-workflow / agent capabilities are enabled for your org. +Complete [Challenge 6](../challenge-06/solution-06.md). Confirm GitHub Actions is enabled on your repository and that you can use the Copilot engine for agentic workflows (see the engine authentication note in [Challenge 7](../../challenges/challenge-07.md)). Agentic workflows do not need Azure. ## Approach @@ -28,7 +28,7 @@ Review the output ~3 min ### Task 2: Author the workflow -- Create a GitHub Agentic Workflow that performs that one task autonomously. +- Create a GitHub Agentic Workflow that performs that one task autonomously. Fastest path: `gh extension install github/gh-aw`, then `gh aw add-wizard githubnext/agentics/issue-triage`. It writes `.github/workflows/issue-triage.md` plus the compiled `.lock.yml` and opens a pull request. Merge it, then edit the Markdown to fit Octocat Supply labels (`backlog`, `priority:*`) and run `gh aw compile` again. ### Task 3: Define triggers and guardrails @@ -45,7 +45,8 @@ Review the output ~3 min ## Common blockers - **Workflow too ambitious (auto-changing code)** → start with triage/labelling. -- **Doesn't trigger** → trigger config mismatch or insufficient permissions. +- **Doesn't trigger** → trigger config mismatch or insufficient permissions. Also check that both the `.md` and the compiled `.lock.yml` are committed under `.github/workflows/` at the repository root. +- **Run fails at the agent step** → engine authentication. Add `permissions: copilot-requests: write` or a `COPILOT_GITHUB_TOKEN` secret. - **Over-broad permissions** → tighten to least privilege. - **No-op / nothing to review** → ensure the task is real and the trigger fired against actual state.