Capstone: design the Azure sandbox architecture
Design identity, networking, data, messaging, budget, RPO and RTO for a small API and worker.
By Invicly Tech, , in Microsoft Azure Cloud Engineering. About 14 minutes to read.
In short
The capstone starts on paper. You design a small system: a containerised API that accepts uploads, a worker that processes them, a storage account for blobs and a queue, and one managed identity per app. The design names every service and tier, every identity and its roles, the budget, the teardown list, and the recovery targets, so you can deploy it and later judge whether it met them.
Think of it like this: It is the building plan you hand the inspector before anyone pours concrete: rooms, doors, keys, budget and fire exits are all on it.
Explained simply
The capstone pulls the whole path together into one small project. You will build a photo-resize service. People upload an image to an API. The API saves it and leaves a note on a queue. A worker picks up the note, makes a thumbnail, and saves the result. It is small, but it has every part a real system has.
Before you build, you design. A design is a short document and a diagram. It says which Azure services you use and at which size, which identities exist and what each may do, how much you will spend, and how you will recover if something breaks. Writing it first saves you from expensive changes later.
The minimum you must deploy is Azure Container Apps for the API and worker, a container registry for the images, one storage account for the files and the queue, and a managed identity for each app. You also add monitoring and a budget alert. A PostgreSQL database and a Service Bus queue are optional extras you can design and add later.
Two numbers describe recovery. RPO, the recovery point objective, is how much recent data you could lose. RTO, the recovery time objective, is how long you could be down. For a lab, an RPO of 24 hours and an RTO of 2 hours are fair targets. Code is safe in Git; the uploaded files are what need protecting.
This costs real money, though only a little if you clean up. Expect a few dollars if you finish within a week and delete everything. Set a budget alert first. If you cannot use a subscription, do the design fully and run the containers locally with Docker and Azurite, the free storage emulator.
Press Play on a diagram to walk through it one step at a time.
- 1Client
Calls the API at its azurecontainerapps.io HTTPS address
- 2Container Apps ingress
Public HTTPS for the API only; the worker has no ingress
- 3API container (id-api)
Writes blobs to uploads, puts a message on the jobs queue
- 4Worker container (id-worker)
Reads the queue and uploads, writes results
- 5Storage account
Containers uploads and results, queue jobs; shared keys off
- 6Monitoring
Log Analytics workspace and Application Insights
- Container Apps environment with API and worker
- Container registry for the images
- Storage account: blobs and a queue
- Two user-assigned managed identities
- Log Analytics, Application Insights, budget alert
- Azure Database for PostgreSQL flexible server for job records
- Service Bus queue with dead-lettering instead of Storage queue
- Private endpoints and a VNet-integrated environment
- Entra authentication for the database
- Client to ca-api (id-api): POST /images with cat.jpg1POST /images with cat.jpg
- ca-api (id-api) to Storage account: Put blob uploads/{id}.jpg2Put blob uploads/{id}.jpg
- ca-api (id-api) to Storage account: Send message {id} to jobs queue3Send message {id} to jobs queue
- ca-api (id-api) to Client: 202 Accepted with job id4202 Accepted with job id
- ca-worker (id-worker) to Storage account: Receive message, read blob5Receive message, read blob
- ca-worker (id-worker) to Storage account: Write results/{id}-thumb.jpg, delete message6Write results/{id}-thumb.jpg, delete message
In depth
Draw request and identity boundaries
Draw two kinds of line on your diagram. Request lines show traffic: client to API over HTTPS, API to Blob Storage, API to the queue, worker to the queue and to Blob Storage. Identity boundaries show who can do what. Draw a box around each app with its identity name, and label each arrow that crosses into storage with the exact role that allows it.
The API's identity, id-api, may write to the uploads container and send queue messages. The worker's identity, id-worker, may read uploads, write results and process queue messages. Neither may manage resources. The deploy identity used by GitHub Actions sits outside both boxes: it manages resources in one resource group and never touches data. Humans get Reader on the resource group and use the deploy pipeline for changes.
- id-api: Storage Blob Data Contributor on uploads, Storage Queue Data Message Sender on jobs
- id-worker: Storage Blob Data Reader on uploads, Storage Blob Data Contributor on results, Storage Queue Data Message Processor on jobs
- Both: AcrPull on the registry
- Deploy identity: Contributor and constrained Role Based Access Control Administrator on the resource group
- No keys: storage shared key access off, registry admin user off
Choose services and tiers
Container Apps on the Consumption plan fits a bursty API and a background worker: it scales to zero when idle and has a monthly free grant, so a quiet lab costs very little. App Service is a valid alternative for the API if you prefer it, but it bills per plan hour even when idle. Use a Basic container registry. Use a Standard general-purpose v2 storage account with locally redundant storage (LRS); production would weigh zone-redundant storage.
Write one line per service: why this one, why this tier, and what production would change. That line is what reviewers look for. For the optional expansion, the Burstable tier of Azure Database for PostgreSQL flexible server and the Basic or Standard tier of Service Bus are the cheapest choices; note that dead-letter queues and sessions need Standard or above in Service Bus, so check the tier comparison before you choose.
Set budget and teardown inventory
Create a budget on the subscription or resource group with an alert at 50, 80 and 100 percent of a small amount. Then write the teardown inventory: every item the project will create, where it lives, and how you will confirm it is gone.
Most items live in the resource group and disappear when you delete it. Some do not. The deploy identity and its federated credential may live in another resource group or in Entra ID. Budgets and subscription-scope deployment history sit above the group. The Log Analytics workspace can be recovered for a period after deletion, and so can a Key Vault if you add one, which may block reusing the same name. Tag everything with project=capstone and owner=your-alias so a single query can find leftovers.
- Resource group rg-capstone-dev
- Container Apps environment and two apps
- Registry
- Storage account
- Identities id-api and id-worker
- Log Analytics and Application Insights
- Outside the group
- Deploy identity and federated credential
- Budget and alert action group
- Subscription-scope deployment records
- Soft-deleted after removal
- Log Analytics workspace (recoverable window)
- Key Vault if added (purge protection rules)
- Outside Azure
- GitHub environment and variables
- Local Docker images
Define RPO and RTO
Split the system into what holds data and what can be rebuilt. Container apps, the registry and settings are rebuilt from Git and Bicep; their RTO is how long a full pipeline run takes, often 10 to 20 minutes. Blobs hold the only copy of users' uploads, so they need protection. Turn on blob soft delete and container soft delete with a short retention such as 7 days, and versioning if you want to recover overwritten files.
Write targets you can test: RPO 24 hours, RTO 2 hours, and a restore you will actually perform in the operate milestone. If you add PostgreSQL, its automatic backups allow point-in-time restore within the retention period you set; record that period and remember a restore creates a new server. Availability is a separate question: one replica can fail without data loss, but it still means downtime.
Plan least-privilege roles
Write every role assignment as a table row: principal, role, scope, reason. Prefer data roles at the narrowest scope that works: a container or queue if you can, otherwise the storage account. Never use Owner or Contributor for an app identity; they manage resources but, for data, the data roles are the ones that count.
The deploy identity is the trickiest. It must create role assignments, which Contributor cannot do. Instead of Owner, grant Role Based Access Control Administrator on the resource group with a condition that only allows assigning the few roles in your table. Review the table against the principle of least privilege: if removing a role breaks nothing, it should not be there. You will prove this in the operate milestone by removing one on purpose.
Learn it in 5 short steps
About 50m each. Track them with a timer in your plan.
- 1Draw request and identity boundaries~50m
- 2Choose services and tiers~50m
- 3Set budget and teardown inventory~50m
- 4Define RPO and RTO~50m
- 5Plan least-privilege roles~50m
Key points
- Draw the request path and mark where each identity's permissions start and stop.
- Pick the cheapest tier that proves the design, and write down what would change for production.
- Write the teardown inventory before you deploy, including things outside the resource group.
- Set RPO and RTO per component: code and infrastructure rebuild from Git; data needs backups.
- One identity per app, with data roles scoped to the storage account, not the subscription.
Key terms
Tap a card to flip it. 0/5 known
Examples
The one-page design for Contoso Thumbnails
This is a filled-in design summary you can copy and adapt. It fits on one page and covers every item reviewers check: services and tiers, identities, budget, recovery and what production would change. Keep it in the repository as docs/design.md so it is versioned next to the Bicep.
Services: Container Apps (Consumption) ca-api + ca-worker; ACR Basic;
Storage StorageV2 LRS: containers uploads, results; queue jobs.
Identities: id-api, id-worker (user-assigned); deploy: id-gh-deploy (OIDC).
Network: public HTTPS ingress on ca-api only; worker has no ingress.
Secrets: none; shared keys off; ACR admin off.
Budget: 10 USD/month, alerts 50/80/100%.
RPO 24h (blob soft delete 7 days, versioning on); RTO 2h (pipeline rebuild).
Region: one region; production adds zone redundancy and private endpoints.
Optional: PostgreSQL flexible server (Burstable) + Service Bus queue.
Teardown: rg-capstone-dev, id-gh-deploy, budget, GitHub env.Role assignment table, checked against a real need
Each row must answer: which call fails without this role? If you cannot name one, delete the row. The table also becomes the source for the Bicep role assignment module, so design and code match. Evidence for the deploy milestone is az role assignment list output that matches this table exactly.
principal role scope fails without it
id-api Storage Blob Data Contributor container uploads PUT blob
id-api Storage Queue Data Message Sender queue jobs send message
id-worker Storage Blob Data Reader container uploads GET blob
id-worker Storage Blob Data Contributor container results PUT thumbnail
id-worker Storage Queue Data Message Processor queue jobs receive/delete
id-api/worker AcrPull registry image pull
id-gh-deploy Contributor rg-capstone-dev create resources
id-gh-deploy RBAC Administrator (conditioned) rg-capstone-dev assign roles aboveQuick reference
- Minimum: Container Apps (API + worker), registry, storage account (blobs + queue), two managed identities.
- Optional: PostgreSQL flexible server for job records, Service Bus for a queue with dead-lettering.
- Every arrow that crosses into storage needs a named data role at the narrowest scope.
- RPO = data you can lose; RTO = time you can be down. Rebuildable parts need RTO only.
- Tag everything project=capstone so az resource list --tag finds leftovers.
- Budget alert before the first deployment, not after the first bill.
- Write what production would change next to every tier you pick.
Common mistakes
- Designing for production scale (zones, premium tiers, private endpoints everywhere) and blowing the lab budget.
- Giving both apps one shared identity with Contributor, which hides who did what and grants too much.
- Leaving Entra objects such as the deploy app registration off the teardown list.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List every resource and object your capstone will create, grouped by where it lives, with the command or Portal page you will use to confirm each one is gone.
- Exercise 2medium
Write the RPO, RTO and protection setting for each component: API, worker, registry, uploads, results, and optional PostgreSQL.
- Exercise 3hard
Extend the design with the optional PostgreSQL and Service Bus. Update the diagram layers, role table, cost lines and teardown list, and explain one new failure mode each adds.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Can I use App Service instead of Container Apps?
- Yes for the API. App Service is part of the allowed minimum. The worker is simpler on Container Apps or as a WebJob, and App Service bills per plan hour even when idle.
- Why a Storage queue and not Service Bus?
- It keeps the minimum to one storage account and costs almost nothing. Service Bus adds dead-lettering, sessions and richer delivery features, so it is the optional upgrade.
- How much will the capstone cost?
- With Consumption Container Apps, Basic registry and LRS storage, a week of light use usually costs a few dollars. Check the pricing calculator for your region and always set a budget alert.
- Do I need private endpoints?
- Not for the minimum. Note in the design that production would add a VNet-integrated environment and private endpoints, and explain the extra cost and DNS work.