-
Notifications
You must be signed in to change notification settings - Fork 102
Azure skills update for verification of functionality and role assignments #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
ecd4e74
d65b0bc
e98eabb
aeb26fa
d1aa5a1
2120443
04a9156
90328df
2e9a8d4
d444e34
04431b7
0f2cf8e
220bcda
f78284d
e132b11
bd4307d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Functional Verification | ||
|
|
||
| Verify that the application works correctly — both UI and backend — before proceeding to validation and deployment. This step prevents deploying broken or incomplete functionality to Azure. | ||
|
|
||
| ## When to Verify | ||
|
|
||
| After generating all artifacts (code, infrastructure, configuration) and applying security hardening — but **before** marking the plan as `Ready for Validation`. | ||
|
|
||
| ## Verification Checklist | ||
|
|
||
| Use `ask_user` to confirm functional testing with the user: | ||
|
|
||
| ``` | ||
| "Before we proceed to deploy, would you like to verify the app works as expected? | ||
| We can test both the UI and backend to catch issues before they reach Azure." | ||
| ``` | ||
|
|
||
| ### Backend Verification | ||
|
|
||
| | Check | How | | ||
| |-------|-----| | ||
| | **App starts without errors** | Run the app and confirm no startup crashes or missing dependencies | | ||
| | **API endpoints respond** | Test core routes (e.g., `curl` health, list, create endpoints) | | ||
| | **Data operations work** | Verify CRUD operations against storage, database, or other services | | ||
| | **Authentication flows** | Confirm auth works (tokens, managed identity fallback, login/logout) | | ||
| | **Error handling** | Verify error responses are meaningful (not unhandled exceptions) | | ||
|
|
||
| ### UI Verification | ||
|
|
||
| | Check | How | | ||
| |-------|-----| | ||
| | **Page loads** | Open the app in a browser and confirm the UI renders | | ||
| | **Interactive elements work** | Test buttons, forms, file inputs, navigation links | | ||
| | **Data displays correctly** | Verify lists, images, and dynamic content render from the backend | | ||
| | **User workflows complete** | Walk through the core user journey end-to-end (e.g., upload → view → delete) | | ||
|
Comment on lines
+18
to
+35
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you expect the agent to respond to these tasks? What type of results are you seeing in your testing?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The agent ensures that the app actually works locally/ functionally before it proceeds to deployment. It runs these checks as part of the azure-prepare step. Previously, while I was trying to deploy an app the agent went straight to deploy a broken app only to find out that the app doesn't actually work/ loads/ UI is broken. When i asked the agent why it didn't check this functionality before deploying, it responded - |
||
|
|
||
| ## Decision Tree | ||
|
|
||
| ``` | ||
| App artifacts generated? | ||
| ├── Yes → Ask user: "Would you like to verify functionality?" | ||
| │ ├── User says yes | ||
| │ │ ├── App can run locally? → Run locally, verify backend + UI | ||
| │ │ ├── API-only / no UI? → Test endpoints with curl or similar | ||
| │ │ └── Static site? → Open in browser, verify rendering | ||
| │ │ Then: | ||
| │ │ ├── Works → Proceed to Update Plan (step 7) | ||
| │ │ └── Issues found → Fix issues, re-test | ||
| │ └── User says no / skip → Proceed to Update Plan (step 7) | ||
| └── No → Go back to Generate Artifacts (step 3) | ||
KarishmaGhiya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ## Running Locally | ||
|
|
||
| For apps that can run locally, help the user start the app based on the detected runtime: | ||
|
|
||
| | Runtime | Command | Notes | | ||
| |---------|---------|-------| | ||
| | Node.js | `npm install && npm start` | Set `PORT=3000` if not configured | | ||
| | Python | `pip install -r requirements.txt && python app.py` | Use virtual environment | | ||
| | .NET | `dotnet run` | Check `launchSettings.json` for port | | ||
| | Java | `mvn spring-boot:run` or `gradle bootRun` | Check `application.properties` | | ||
|
|
||
| > ⚠️ **Warning:** For apps using Azure services (e.g., Blob Storage, Cosmos DB), local testing requires the user to be authenticated via `az login` with sufficient RBAC roles, or to have local emulators configured (e.g., Azurite for Storage). | ||
|
|
||
| ## Record in Plan | ||
|
|
||
| After functional verification, add a note to `.azure/plan.md`: | ||
|
|
||
| ```markdown | ||
| ## Functional Verification | ||
| - Status: Verified / Skipped | ||
| - Backend: Tested / Not applicable | ||
| - UI: Tested / Not applicable | ||
| - Notes: <any issues found and resolved> | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Role Assignment Verification | ||
|
|
||
| Verify that all RBAC role assignments in the generated infrastructure are correct and sufficient before testing functionality. Incorrect or missing roles are a common cause of runtime failures. | ||
|
|
||
| ## When to Verify | ||
|
|
||
| After security hardening (step 4) and **before** functional verification (step 6). Role issues surface as cryptic auth errors during testing — catching them here saves debugging time. | ||
|
|
||
| ## Verification Checklist | ||
|
|
||
| Review every resource-to-identity relationship in the generated Bicep/Terraform: | ||
|
|
||
| | Check | How | | ||
| |-------|-----| | ||
| | **Every service identity has roles** | Each app with a managed identity must have at least one role assignment | | ||
| | **Roles match data operations** | Use service-specific **data-plane** roles for data access (see mapping table below); use generic Reader/Contributor/Owner only for management-plane operations | | ||
| | **Scope is least privilege** | Roles scoped to specific resources, not resource groups or subscriptions | | ||
| | **No missing roles** | Cross-check app code operations against assigned roles (see table below) | | ||
| | **Local dev identity has roles** | If testing locally, the user's identity needs equivalent roles via `az login` | | ||
|
|
||
| ## Common Service-to-Role Mapping | ||
|
|
||
| | Service Operation | Required Role | Common Mistake | | ||
| |-------------------|---------------|----------------| | ||
| | Read blobs | Storage Blob Data Reader | Using generic Reader (no data access) | | ||
| | Read + write blobs | Storage Blob Data Contributor | Missing write permission | | ||
| | Generate SAS via user delegation | Storage Blob Delegator + Data Reader/Contributor | Forgetting Delegator role | | ||
| | Read Key Vault secrets | Key Vault Secrets User | Using Key Vault Reader (no secret access) | | ||
| | Read + write Cosmos DB | Cosmos DB Built-in Data Contributor | Using generic Contributor | | ||
| | Send Service Bus messages | Azure Service Bus Data Sender | Using generic Contributor | | ||
| | Read queues | Storage Queue Data Reader | Using Blob role for queues | | ||
|
|
||
| ## MCP Tools for Verification | ||
|
|
||
| Use Azure MCP tools to check existing role assignments: | ||
|
|
||
| ``` | ||
| azure__role(command: "role_assignment_list", scope: "<resourceId>") | ||
| ``` | ||
|
|
||
| Compare the output against what the infrastructure code generates. | ||
KarishmaGhiya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Decision Tree | ||
|
|
||
| ``` | ||
| For each app identity in the generated infrastructure: | ||
| ├── Has role assignments? | ||
| │ ├── No → Add required role assignments to Bicep/Terraform | ||
| │ └── Yes → Check each role: | ||
| │ ├── Role matches code operations? → ✅ OK | ||
| │ ├── Role too broad? → Narrow to least privilege | ||
| │ └── Role insufficient? → Upgrade or add missing role | ||
| │ | ||
| For local testing: | ||
| ├── User identity has equivalent roles? | ||
| │ ├── No → Grant roles via CLI or inform user | ||
| │ └── Yes → ✅ Ready for functional verification | ||
| ``` | ||
|
|
||
| > ⚠️ **Warning:** Generic roles like `Contributor` or `Reader` do **not** include data-plane access. For example, `Contributor` on a Storage Account cannot read blobs — you need `Storage Blob Data Contributor`. This is the most common RBAC mistake. | ||
|
|
||
| ## Record in Plan | ||
|
|
||
| After role verification, update `.azure/plan.md`: | ||
|
|
||
| ```markdown | ||
| ## Role Assignment Verification | ||
| - Status: Verified / Issues Found | ||
| - Identities checked: <list of app identities> | ||
| - Roles confirmed: <list of role assignments> | ||
| - Issues: <any missing or incorrect roles fixed> | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # Live Role Verification | ||
|
|
||
| Query Azure to confirm that provisioned RBAC role assignments are correct and sufficient for the application to function. This complements the static role check in azure-prepare by validating **live Azure state**. | ||
|
|
||
| ## How It Differs from azure-prepare's Role Check | ||
|
|
||
| | Check | Skill | What It Verifies | | ||
| |-------|-------|-----------------| | ||
| | **Static** | azure-prepare | Generated Bicep/Terraform has correct role assignments in code | | ||
| | **Live** | azure-validate (this) | Provisioned Azure resources actually have the right roles assigned | | ||
JasonYeMSFT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Both checks are needed because: | ||
| - Bicep may be correct but provisioning could fail silently for roles | ||
| - Manual changes or policy enforcement may alter role assignments | ||
| - Previous deployments may have stale or conflicting roles | ||
|
|
||
| ## When to Run | ||
|
|
||
| After infrastructure validation (step 2) and build verification (step 3) — before recording proof (step 5). Only run this step if resources have been provisioned (i.e., after `azd provision` or a prior `azd up`). | ||
|
|
||
| ## Verification Steps | ||
|
|
||
| ### 1. Identify App Identities | ||
|
|
||
| Read `.azure/plan.md` to find all services with managed identities. Then query Azure for their principal IDs: | ||
|
|
||
| ```bash | ||
| # App Service | ||
| az webapp identity show --name <app-name> -g <resource-group> --query principalId -o tsv | ||
|
|
||
| # Container App | ||
| az containerapp identity show --name <app-name> -g <resource-group> --query principalId -o tsv | ||
|
|
||
| # Function App | ||
| az functionapp identity show --name <app-name> -g <resource-group> --query principalId -o tsv | ||
| ``` | ||
|
|
||
| ### 2. Query Live Role Assignments | ||
|
|
||
| Use MCP tools to list role assignments for each resource: | ||
|
|
||
| ``` | ||
| azure__role(command: "role_assignment_list", scope: "<resourceId>") | ||
| ``` | ||
|
|
||
| Or via CLI: | ||
|
|
||
| ```bash | ||
| az role assignment list --scope <resourceId> --output table | ||
| ``` | ||
|
|
||
| ### 3. Cross-Check Against Requirements | ||
|
|
||
| For each identity, verify the assigned roles match what the app needs: | ||
|
|
||
| | App Operation | Expected Role | Scope | | ||
| |---------------|---------------|-------| | ||
| | Read/write blobs | Storage Blob Data Contributor | Storage account | | ||
| | Generate user delegation SAS | Storage Blob Delegator | Storage account | | ||
| | Read secrets | Key Vault Secrets User | Key Vault | | ||
| | Send messages | Azure Service Bus Data Sender | Service Bus namespace | | ||
| | Read/write documents | Cosmos DB Built-in Data Contributor | Cosmos DB account | | ||
|
|
||
| ### 4. Check for Common Issues | ||
|
|
||
| | Issue | How to Detect | Fix | | ||
| |-------|---------------|-----| | ||
| | Role assigned at wrong scope | Role on resource group but needed on specific resource | Reassign at resource scope | | ||
| | Generic role instead of data role | `Contributor` assigned but no data-plane access | Replace with data-plane role (e.g., `Storage Blob Data Contributor`) | | ||
| | Missing role entirely | No assignment found for identity on target resource | Add role assignment to Bicep and redeploy | | ||
| | Stale role from previous deployment | Old principal ID with roles, new identity without | Clean up old assignments, add new ones | | ||
|
|
||
| ## Decision Tree | ||
|
|
||
| ``` | ||
| Resources provisioned? | ||
| ├── No → Skip live check (nothing to query yet) | ||
| └── Yes → For each app identity: | ||
| ├── Query role assignments on target resources | ||
| ├── Compare against expected roles from plan | ||
| │ ├── All roles present and correct → ✅ Pass | ||
| │ ├── Missing roles → ❌ Fail — add to Bicep, redeploy | ||
| │ └── Wrong scope or generic roles → ⚠️ Warning — fix and redeploy | ||
| └── Record results in Validation Proof | ||
| ``` | ||
|
|
||
| ## Record in Validation Proof | ||
|
|
||
| Add live role verification results to **Section 7: Validation Proof** in `.azure/plan.md`: | ||
|
|
||
| ```markdown | ||
| ### Live Role Verification | ||
| - Command: `az role assignment list --scope <resourceId>` | ||
| - Results: | ||
| - <identity> → <role> on <resource> ✅ | ||
| - <identity> → missing <expected-role> on <resource> ❌ | ||
| - Status: Pass / Fail | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.