Back to Terraform

Capstone H: Deliver a Private Azure Application

November 6, 2026 Wasil Zafar 45 min read

Build an Azure application with managed identity, private data access and independent readiness evidence.

Table of Contents

  1. Define the Minimal Service and Its Cost Boundary
  2. Partition Identity, State, Artifacts and Data Ownership
  3. Promote a Reviewed Plan and Immutable Application Artifact
  4. Prove the Service Through Positive and Negative Cases
  5. Recover a Controlled Failure and Submit the Evidence

Define the Minimal Service and Its Cost Boundary

A capstone is a delivery with a reviewer, not a longer tutorial. You will build one private request path, split it across three ownership scopes, prove it with positive and negative cases, promote one reviewed plan with one immutable package, break it once on purpose, and hand over the evidence. The result is a small working service plus the record that it behaves as designed.

Keep the required path small enough to finish. One region, one Linux App Service plan, one app, one user-assigned identity, one storage account with one container, one Key Vault, and three private endpoints: the app, the blob service and the vault. The deployment hostname rides the app endpoint as a second record in the same zone, not as another endpoint. A second region, a database and an edge layer are decisions you record and defer, not requirements.

Private means two separate claims, not one. Inbound, the app hostname resolves only inside the virtual network. Outbound, the app reaches blob and vault through private endpoints from its integration subnet. A closed front door says nothing about the back one, so each claim gets its own proof later.

Identity is the only credential on the path. The app presents a user-assigned identity, requests a short-lived token for each service audience, and keeps nothing in its settings except the identity's client id. A stored key would make the entire private network an expensive way to protect a secret that already sits in state.

The public path is closed on purpose, and that closure is a deliverable. Disabling public access on the app turns the default hostname into a name that resolves publicly, connects to a front end, and is refused with a 403. That refusal is the evidence that the private endpoint is the only way in, and it is tested from outside the network rather than assumed.

Prerequisites are account facts, and they fail before Terraform does. A missing provider registration, a regional quota, or an identity that cannot write role assignments will reject a plan that looks correct. Check them in this order, because each one costs more to discover later than the one above it.

PrerequisiteWhy the build stops without itHow to confirm
Resource providers for Web, Storage, KeyVault, Network, ManagedIdentitythe resource type cannot be created in the subscriptionprovider list shows each one as registered
App Service quota for the chosen SKU in the regionthe plan is rejected or silently cappedquota view for the subscription and region
Owner or User Access Administrator at the workload scoperesources apply, then every role assignment failseffective role check before the first plan
Authority to create private DNS zones and VNet linksprivate endpoints come up but nothing resolvesplatform-scope permission check
A deployment path into the VNeta closed SCM endpoint rejects the last mile of the releaserunner subnet, plus the SCM record in the app zone
A budget and an alert ownercost overrun is discovered after the factbudget at the subscription or group scope

Three implementation paths exist, and only one is the reference. Linux App Service on a B1 plan gives a stable private endpoint story and a predictable bill, but no deployment slots. A slot starts at S1, which moves the plan line up and should raise the ceiling with it. Functions Flex Consumption is a valid substitute with a different package path, and Container Apps is out of scope because it adds a cluster, an environment and a second ingress model. If you substitute, record the swap in D1 and adjust the proof set; do not change paths halfway through the build.

A capstone is accepted against deliverables, not intentions. Each row below becomes one artifact in the evidence pack, and the review is a matter of checking that the artifact exists and says what it claims.

IDDeliverableAccepted when
D1Scope and cost recordOne region, one hostname, one ceiling and one named owner
D2Ownership matrixEvery object has one root, one state key and one credential scope
D3Platform and workload rootsBoth apply and destroy without console edits
D4Proof logPositive and negative cases recorded with the failing layer named
D5Promotion recordPlan digest and package digest approved together and applied once
D6Recovery and cleanup reportOne controlled failure recovered, three no-change plans, inventory closed

Scope is a written boundary, and the exclusions are part of it. A project that says "the private application" cannot fail a test, because nothing is outside the sentence. Name what is in, name what is out, and attach the date of the decision.

SurfaceIncludedExcluded
InboundOne app hostname, private endpoint, public access disabledCustom domains, Front Door, WAF
OutboundOne integration subnet, private endpoints for blob and vaultOn-premises routing, firewall egress inspection
IdentityOne user-assigned identity for the app, one federated identity for CIBreak-glass accounts, cross-tenant access
DataOne container, one secret, one recovery windowDatabase migration, analytics copies
CostOne plan, three endpoints, three zones, capped loggingMulti-region, paid edge tiers, reserved capacity

Figure 1 turns the scope into a decision path. The required branch is a private app with private data access; the public branch is a different project with its own approval, because it changes what the negative test is allowed to expect.

Define the Minimal Service and Its Cost Boundary
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    S["Scope record
one region · one hostname · one ceiling"] --> P["Platform root
VNet · subnets · DNS zones"] P --> A["App Service B1
private inbound only"] A --> I["User-assigned identity
one per app"] I --> B["Blob container
private endpoint"] I --> V["Key Vault secret
private endpoint"] A --> C{"Public path
still required?"} C -->|"no"| X["Closed by design
403 recorded from outside"] C -->|"yes"| R["Separate project
new approval and proof"] B --> OK["Acceptance review
positive and negative evidence"] V --> OK X --> OK CO["Budget alert at eighty percent
daily cap on logs"] -.-> OK classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class S,P,A primary; class I,B,V secondary; class C,CO warn; class OK,X ok; class R danger;

The cost boundary is two numbers and a list. Set a monthly ceiling in the scope record, an alert at eighty percent of it, and a daily cap on log ingestion, because telemetry is the line item that grows without anyone approving a resource. The list of drivers explains which line moves first when the ceiling is reached.

DriverWhat scales itTreatment inside the ceiling
App Service planalways-on hours for the chosen SKUone B1 plan, no autoscale
Private endpointsone per endpoint per hour, plus data processedthree endpoints, no per-environment duplicates
Private DNS zoneszones, links and query volumethree zones, one link per zone
Storagestored bytes plus operationsone container, soft delete for one week
Key Vaultdata-plane operations on a standard vaultone secret, no HSM, no key operations
Logs and metricsingested volume per daydaily cap, short retention, sampled traces

A ceiling without an owner is a wish. Name the person who receives the alert and the action they take: stop the plan, delete the lab, or approve an increase in writing. For this capstone the reference ceiling is one hundred US dollars per month in one region at list price, and the alert is the control that keeps it honest rather than a forecast.

Naming is part of the boundary. Choose a short project prefix and use it everywhere: resource group, plan, app, storage account, vault, zones, state container and artifact prefix. A name that encodes the environment and the owner makes a resource list readable, and a resource list is what you will reconcile at the end.

The private request path, the boundary that closes it, and the cost line beside it A client outside the virtual network reaches the App Service front end and is refused. Inside the virtual network, the app uses an integration subnet to reach blob and vault through private endpoints, and the zone strip shows the three private DNS zones that make those names resolve. A side panel fixes the monthly ceiling and the alert that enforces it. One app, one boundary, one bill The public name stops at the front end. The private name reaches the data plane. Client outside the VNet public DNS answers, the front end refuses with 403 no shared path App Service front end public network access disabled, private endpoint only VNet boundary integration subnet separate from the endpoint subnet App Service B1 Linux identity attached no deployment slot Endpoints and DNS blob endpoint vault endpoint app and scm names Blob container app data soft delete no shared key Key Vault one secret RBAC only private endpoint Private DNS zones privatelink.blob.core.windows.net · privatelink.vaultcore.azure.net · privatelink.azurewebsites.net Cost ceiling 100 USD per month, one region, list price App Service plan B1 three private endpoints three DNS zones and links one container, one secret capped log ingestion Alert at 80 percent, daily cap on logs, one named owner. The alarm is the control. The ceiling is the decision it protects. A closed public path is proven from outside, not inferred from a plan that says public access is disabled.

Figure 2 is the map the rest of the project tests. Read it from the outside in: the public name stops at the front end, the integration subnet carries outbound traffic, the endpoint subnet holds the private addresses, and the zone strip is what makes the private names resolve at all. Every arrow is a handoff with an owner.

Write the one-sentence contract before the first plan. "A client inside the VNet calls the app over TLS, the app writes one blob and reads one secret as its own identity, and a client outside the VNet gets nothing." If the sentence needs a second "and" for a second data source, the scope grew and the cost table is already wrong.

Partition Identity, State, Artifacts and Data Ownership

Three scopes, three lifetimes. The ops scope holds state and release artifacts and outlives everything. The platform scope holds the network and the DNS zones. The workload scope holds the app, its identity, its data and the grants on that data. A resource that appears in two scopes has two destroy paths, and the faster one wins during an incident.

The state backend must survive the workload it describes. Keep the state account and its containers in the ops scope, with versioning, soft delete and a retention window that covers your rollback window. If the state lives in the resource group you are about to destroy, the destroy plan succeeds and the record of what it removed disappears with it.

State access is a data-plane grant too. Authenticate the backend with Entra rather than an account key, and give the Terraform identity a blob data role on the state container only. An account key in a backend configuration is a secret in a file that every pipeline step can read, and it authorizes every container in the account.

A grant belongs where its target lives. The app identity is created in the workload scope because the app is, and the roles on the blob container and the vault are declared in that same scope because that is where the objects are. The deploy identity is owned by the platform team, so its read grant on the artifact container is declared in the ops scope. Reviewers then find every permission in the root that owns the thing being protected.

One identity per app, and a different identity for Terraform. The app identity cannot read state, cannot assign roles and cannot delete the network. The CI identity authenticates through a federated credential, so there is no client secret to rotate, and its write scope is the two workload roots. A shared identity collapses the review into "whoever can apply can do anything".

Data ownership is a namespace and a retention rule, not a bucket. Name the container for the product and the environment, decide who may delete objects, and set soft delete to a window you can afford to wait out. The application writes; the platform team does not browse; the recovery owner is named in the data record.

SurfaceOwnerScope and rootState keyCredentialDestroy rule
State account and containersplatformopsops/bootstrapEntra data role on the state containerprevent_destroy, retained
Release artifactsbuildopsops/bootstrapwrite on the artifact containerretained for the rollback window
VNet, subnets, NSGsnetworkplatformplatform/prodnetwork contributordestroyed last
Private DNS zones and linksnetworkplatformplatform/prodzone contributordestroyed with the platform
App plan and appapplicationworkloadworkload/prodwebsite contributordestroyed first
User-assigned identityapplicationworkloadworkload/prodmanaged identity operatorafter its grants are gone
Blob container and vaultdataworkloadworkload/proddata-plane rolesafter the app is gone
Role assignments on datadataworkloadworkload/produser access administratorbefore the objects

The backend is configured in two halves. Put the non-secret values in the backend block and pass the environment-specific ones at init time, so one root can serve a lab and a review without editing files. The state key is the part that must never be shared: two roots on one key produce two reviewers, one lock and alternating plans.

Artifacts are not state and must not share a container. A state container holds the current and historical truth of the infrastructure; an artifact container holds release bytes that must never change. Separate containers mean separate role assignments, separate retention rules and a blast radius that stops at the boundary you drew.

Reading another root's state is a boundary leak. Publish zone ids and subnet ids as outputs, consume them as variables, and let the pipeline pass them between jobs. A remote state data source makes one root depend on the internal shape of another, so a refactor in the platform becomes an outage in the workload.

A duplicate object is worse than a missing one. A missing record fails once and loudly; a duplicated record passes both reviews and then reverts on alternate applies, which looks like provider drift and teaches the team to ignore the plan. If two roots both want to own a DNS record, one of them is wrong.

Figure 3 assigns one owner to every object and turns each cross-scope dependency into a named artifact. The dashed lines are state access, the solid line is a published variable, and the artifact arrow carries bytes rather than permissions.

Three ownership scopes, their state keys, and the artifacts that cross between them The ops scope holds the state account and the artifact container and outlives the others. The platform scope holds the network and private DNS zones and publishes zone identifiers as variables. The workload scope holds the app, identity, data and grants. A strip below names the three handoffs and a footer warns that a shared state key gives two roots one blast radius. One owner per object, artifacts across the line State outlives the workload. Variables cross scopes. Credentials do not. Ops scope state key ops/bootstrap State account versioning and soft delete tfstate container one key per root Artifact container release, commit, digest Retained after workload destroy prevent_destroy on the container Platform scope state key platform/prod VNet and three subnets integration, endpoints, runner Private DNS zones three zones, one link each Zone records app, scm, blob, vault Publishes zone ids as outputs, never as remote state reads Workload scope state key workload/prod Plan and app private inbound only User-assigned identity one per app, no sharing Container and vault private endpoints attached Grants on the container and vault live with the targets, not the identity Handoffs, in one direction each State access: both roots read and lock their own key in the ops container. Zone ids and subnet ids: platform outputs into workload variables. Package digest: build record into the deploy step. Two roots on one state key is one blast radius with two approvers, and neither can review the other.

The mechanics matter more than the picture, because the failures are mechanical. Figure 4 follows the pair from plan to no-change plan and keeps the four usual mistakes on the page: a shared key, a grant in the wrong root, a remote state read, and a destroy order that removes the state before the workload.

Partition Identity, State, Artifacts and Data Ownership
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    O["Ops scope
state and artifact containers"] --> ST["Backend over Entra
versioning and soft delete"] PL["Platform plan
VNet · zones · links"] --> Z["Zone ids as outputs
not remote state"] Z --> W["Workload plan
app · identity · endpoints · grants"] W --> G{"Grant declared in
the target scope?"} G -->|"no"| X1["Grant in the identity root
review cannot see it"] G -->|"yes"| AP["Apply platform first
then the workload"] AP --> D{"Destroy workload
before ops?"} D -->|"no"| X2["State removed before
the thing it describes"] D -->|"yes"| OK["Three no-change plans
exit code 0"] ST -.->|"one key for two roots"| X3["Alternating plans
one lock, two owners"] W -.->|"remote state read"| X4["Boundary leak
unreviewable change"] X3 --> F["Split the key
then re-plan both"] X4 --> F classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class O,PL,W primary; class ST,Z,AP secondary; class G,D warn; class OK ok; class X1,X2,X3,X4 danger; class F warn;

A state key is a review boundary. If two people can run apply against the same key at the same time, the lock decides who wins and the plan nobody read becomes the change. Separate keys per scope turn that race into a merge conflict you can discuss.

The identity's name is not its authorization. A principal id that appears in the app's settings proves the identity exists; only the assignment at the target proves the app can read the blob. Record both, side by side, because the first is visible in the plan and the second is the one that fails at runtime.

Promote a Reviewed Plan and Immutable Application Artifact

Promotion is one decision with two digests. The infrastructure plan and the application package travel through the same approval, and the approval names the hash of each. A plan approved against one package digest and applied with another is an unreviewed deployment with a reviewed file name.

Pin the producer, not just the product. Terraform 1.17.1, hashicorp/azurerm 5.13.0 and hashicorp/azuread 3.10.0 belong in the version constraints, in the lock file and in the workflow that runs them. A different CLI or provider produces a different plan from the same configuration, so the record has to name all three.

Modules are pinned the same way. If you reuse one, reference a tag and record the commit it resolves to, because a tag that moves changes the graph without changing your file. The reference build keeps both roots flat, which removes one supply-chain input but not the habit.

FieldWhat it recordsWhy the review needs it
Commit and treethe exact configuration revieweda branch that moved invalidates the plan
ToolchainCLI and both providers with versionsa different producer makes a different plan
Module referencestag or commit for every modulea moved tag changes the graph silently
Plan digesthash of the saved plan filethe applied bytes match the approved bytes
Package digesthash of the normalized zipthe code under test is the code promoted
Approver and expirya named person and a deadlineapproval is for a change, not a season
State keysone key per scopea shared key erases the boundary

A saved plan is the only thing you may apply. Run the plan with an output file, hash the file, store it encrypted and short-lived, and apply that exact file after approval. A re-plan after approval is a new change, even when the diff looks identical, because the identity and the data underneath it may not be.

The package is identified by its bytes. Build once in a fixed image, normalize timestamps and file modes, hash the zip, and store it under a name that contains the app, the release, the commit and the digest. Assets that are rebuilt during an apply produce a digest that no longer matches the review, which is the quietest way to ship something nobody approved.

Deployment crosses the same private boundary as traffic. With public access disabled, the deployment hostname is private too, so the pipeline needs a runner inside the VNet and a DNS record for the SCM name in the app zone. A pipeline that plans and applies from a hosted agent will fail at the last step, after a green infrastructure apply.

The app must answer with its version. One route returning the release id and the package digest turns every later test into a comparison instead of an opinion. It also gives the rollback decision a value to check, rather than a deployment status to trust.

Schema and data changes are a separate change. Terraform owns the container and the vault; it does not own the rows or the object layout inside them. A migration is a versioned, backwards-compatible step with its own approval, run once and recorded, not a script that runs on every apply because it happens to live in a provisioner.

Rollback is a digest, not a rebuild. Keep the last few packages and their digests for the rollback window, and make a rollback the act of deploying a known digest. Rebuilding the previous commit during an incident tests the build system at the worst possible moment.

Figure 5 shows the two lanes converging on one approval and one apply. The rejected strip below it is the path most teams drift into: approve a plan, re-plan at apply time, and discover the difference only when the version route reports a digest nobody recognises.

Two identity lanes, one approval gate, and the rejected shortcut The artifact lane runs from commit to build to an immutable package digest. The infrastructure lane runs from the lock file to a saved plan and a plan digest. Both digests enter one approval, which releases the saved plan and the same package to the app; the version route then reports the digest for the promotion record. A rejected strip shows re-planning after approval, a mutable latest tag and a console edit. One approval, two digests The plan and the package are approved together and applied once. Artifact lane Commit tree recorded Build once fixed image, normalized zip Immutable package release, commit, digest Infrastructure lane Lock file pinned toolchain Saved plan written to a file Plan digest hash of the saved bytes Approval one person, two digests expiry recorded no re-plan allowed Apply saved plan no fresh plan Deploy digest same bytes Version route reports the digest to the record. Rejected Approve one plan, re-plan at apply time, deploy a mutable latest tag, or edit a setting in the portal between approval and apply.

A promotion record is written before the apply and completed after it. The approver, expiry and both digests go in first; the observed version response and the timestamp go in last. A record reconstructed from memory is a story about a deployment, not evidence of one.

The plan artifact is a secret-adjacent file. It can contain variable values in clear text, so encrypt it, restrict its readers, delete it on a schedule and never attach it to a ticket. Treat it the way you treat the state file, because a plan is a snapshot of the same configuration.

Prove the Service Through Positive and Negative Cases

Evidence is a matrix with one variable per row. A positive case proves the service works; a negative case proves the control that is supposed to stop it does. Add the rows before you run them, because a case invented after a failure is a negotiation with the result.

Read the layer from the signal, not from the symptom. A refusal at the front end, a name that resolves publicly, a port that never answers and a data-plane denial all look like "the app is broken" from a laptop. They fail at four different layers, and each one has a different next check.

IDCaseActionExpectedEvidence
P1Version routerequest the health route from inside the VNet200 with release id and digestresponse body and app log entry
P2Blob write and readwrite one object, read it backboth succeed, same bytesobject name and operation ids
P3Secret readapp reads the configured secretvalue returned, no key in settingsvault audit entry for the identity
P4Private resolutionresolve app, blob and vault names in the VNetCNAME into privatelink, RFC 1918 addressresolver output per name
N1Public app pathrequest the app hostname from outside403 from the front end, no app tracestatus code and source network
N2Public blob pathrequest the blob endpoint from outside403, no data returnedstatus and error code
N3Public vault pathrequest the vault endpoint from outside403, firewall refusalstatus and error code
N4Role removedremove the blob data role, then write403 from the data planeerror code and the plan that restores it
N5Zone link removedunlink the blob zone, then resolve and writepublic address, then a 403 from the public endpointresolution, status and app dependency log
N6Wrong audiencerequest a token for the wrong resource401 before any data callstatus and token audience

Order the probes: name, port, permission, behaviour. A resolver answer proves the name, a completed TLS handshake proves the path, a data-plane call proves the grant, and the version route proves the app. Running them out of order turns a DNS fault into a role investigation, which is how a private application acquires permissions it never needed.

Test the public path from outside and the private path from inside, and never let one stand in for the other. A laptop on a home network can prove the refusal, but it cannot prove the private endpoint; a request from the integration subnet can prove the private path, but it cannot prove the closure. Two source networks, two claims.

Use a resolver, not an application error, to prove DNS. A private name returns a CNAME into the privatelink zone and an address from your VNet range. A public address in the answer means the zone is missing, unlinked, or the client is using a resolver that never sees it, and no role change will fix that.

A refused connection and a refused request are different evidence. A timeout or a reset points at the network path: subnet delegation, an NSG rule or a missing route. A public address followed by a 403 is a DNS fault wearing a firewall's clothes, and a 403 with a permission error points at the data-plane grant. Record which one you observed, because "it failed" collapses the only distinction that matters.

The negative case for permissions must start from a working positive case. Remove the blob role, repeat the exact write that succeeded a minute earlier, and capture the data-plane error. That sequence proves the role was the variable; removing a role on a service that never worked proves nothing.

Telemetry has to show the denial, not hide it. The dependency record should carry the target name, the status code and the identity, so a denied call appears as a dependency failure rather than a generic server error. If the handler turns a 403 into a 500 with no dependency entry, the service is not observable, and the next person will debug the handler instead of the grant.

Propagation is part of the test window. A new data-plane role can take up to ten minutes to become effective, and a 403 inside that window is expected. Put the wait in the test, record the time the assignment was created, and never add a retry loop inside the handler to paper over it.

Figure 6 places the three gates on the path and gives each one a different failure signature. The point of the diagram is the bottom row: the signal tells you which gate to inspect, and inspecting the wrong gate is how a DNS fault becomes an over-broad role.

Three gates on the private request path and the failure signature of each A client inside the virtual network passes name resolution, a private network path and a data-plane authorization check before reaching blob or vault. Below each gate, a failure box names the signal: a public address or NXDOMAIN for DNS, a timeout or reset for the network, and a permission error for the role. A footer states that the first failing gate owns the repair. Three gates, three different refusals The first gate that fails owns the repair. The others are innocent until it passes. Client inside the VNet 1 · Name CNAME into privatelink A record, RFC 1918 zone linked to the VNet 2 · Path private endpoint NIC TCP 443 accepted TLS to the service name 3 · Permission token for the audience role at container scope grant is eventually live Blob or vault data plane Public address or NXDOMAIN Zone, link or resolver. Not a role problem. Timeout or reset no HTTP status NSG, route, delegation or the endpoint state. 403 permission or a 401 on the token Role scope or audience. Plan can look green. Read the first failing gate, then stop. A public answer and a 403 permission error can appear in the same incident. Fixing the role first produces a second, quieter problem. Public path refusal is expected evidence. It is recorded, not remediated.

The evidence flow has one loop, and it is deliberate. Figure 7 runs the positives first, stops if the baseline is broken, runs the negatives, and only then reads the signals. A negative case run against a broken baseline produces a failure that cannot be attributed.

Prove the Service Through Positive and Negative Cases
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    B["Baseline
in-VNet client and public client"] --> P["Positive cases
version · write · secret read"] P --> Q{"All positives
pass?"} Q -->|"no"| X1["Stop
a broken baseline hides the denial"] Q -->|"yes"| N["Negative cases
public path · zone link · role"] N --> S{"Signal names
one gate?"} S -->|"401"| X2["Token audience
or tenant"] S -->|"403 permission"| X3["Data-plane role
at the wrong scope"] S -->|"403 firewall or timeout"| X4["DNS, NSG
or zone link"] S -->|"yes"| E["Evidence pack
one row per case"] E --> R["Acceptance review
and promotion record"] X1 --> F["Repair the baseline
then rerun every row"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class B,P,N primary; class Q,S warn; class E,R ok; class X1,X2,X3,X4 danger; class F warn;

A test that only checks the happy path is a demo. The negative rows are the product here: they show the closure of the public path, the grant at the target scope, and the difference between a network refusal and an authorization refusal. Keep them in the regression set after the capstone is accepted.

Record the source network with every row. The same URL returns a different answer inside and outside the VNet, so a result without a source is not reproducible. Note the client subnet or the runner name beside the status code, and the next reader can repeat the test instead of trusting the screenshot.

Recover a Controlled Failure and Submit the Evidence

Choose a failure with one owner and one repair. Delete the blob zone link from the platform scope in the portal, which is exactly the kind of drift a busy week produces. The app is unchanged, the role is unchanged, and the name stops resolving to the private address, so the failure cannot be confused with a permission change.

Write the hypothesis before you break anything. Expected: resolution for the storage name returns a public address instead of the private one, the app's write path fails while its health route still answers, the platform plan shows exactly one link to add, and the workload plan shows nothing. A prediction that cannot be wrong is not a test.

TimeObserverLayerSignal to record
t0platformchangezone link deleted in the portal
t1client in VNetDNSstorage name resolves to a public address
t2applicationdata planewrite fails, dependency record shows the refusal
t3workload rootplanno changes, so the app is not the cause
t4platform rootplanone link to add

Recovery is applying the declared state, then proving the path. Apply the platform root, wait for the link and the records, resolve the name again, and repeat the exact write that failed. Then run a no-change plan in every scope: exit code 0 means the drift is gone, and exit code 2 means something still differs from the declaration.

Rollback and recovery are different words. A rollback restores the previous release because the new one is wrong. A recovery restores the intended infrastructure because something changed outside the declaration. Here you performed a recovery, and the record should say so, with the drift named and the change that removed it.

The data recovery decision is separate from the infrastructure fix. The link repair restores reachability, not lost objects. Decide from the data record whether soft delete covers the window, whether a restore is required, and who signs for the loss if it is not. A repair that restores the path and silently accepts data loss is an incomplete recovery.

Cleanup is an inventory, not a destroy. Every row below is checked after the destroy, because a resource group that looks empty in the portal can still hold role assignments, private DNS records, soft-deleted vaults or an artifact container you meant to keep.

ObjectOwnerActionCheck after destroy
App and planworkloaddestroy firstapp hostname no longer resolves
Private endpointsworkloaddestroyed with their targetsendpoint count is zero
Role assignmentsworkloadremoved with the objectsno orphan principal grants
Storage containerworkloaddestroyed after the appaccount can be deleted
Vault and secretworkloaddeleted, purge protection decision recordedname is free or deliberately reserved
Zone records and linksplatformdestroyed after the workloadzones hold no records
VNet and subnetsplatformdestroyed lastno peerings or delegations remain
State and artifactsopsretained until the window closesversions and digests still readable

Three nuances decide whether the cleanup is really clean. A soft-deleted vault keeps its globally unique name, so a lab that enables purge protection cannot reuse the name until the window ends. A private DNS zone keeps records after an endpoint is deleted if the zone group was managed by hand. An artifact container with a retention policy refuses deletion until the policy allows it, which is the policy doing its job.

Acceptance is a table a reviewer can close. Every row names the evidence, and the evidence lives in the pack rather than in a chat message. If a row cannot be closed, the project is not failed; it is unfinished, and the row says what is missing.

IDAcceptance criterionEvidence that closes it
A1Public path is closed403 from outside the VNet, with the source network recorded
A2Private name resolves insideCNAME and private address for app, blob and vault
A3Identity is scopedrole assignments at container and vault scope, no subscription-wide grant
A4Data plane works only through the grantpositive write, then a 403 after the role is removed
A5Integrity of the releaseversion route reports the digest in the promotion record
A6Plan is reproducibleapplied plan digest matches the approved digest
A7Failure recoveredtimeline, one-link diff, then a no-change plan
A8Cleanup is completeinventory checked, retained objects listed with an owner
Lab

Recover a Controlled Failure and Submit the Evidence

Status: design-only. No Azure subscription or credential was used to produce this capstone, and none of these steps were executed here. Versions: Terraform CLI 1.17.1, hashicorp/azurerm 5.13.0, hashicorp/azuread 3.10.0, verified 6 November 2026. Every name, id and address below is something you supply in your own sandbox; nothing here is a recorded output.

Prerequisites. A sandbox subscription, one region, permission to create role assignments, a Linux App Service plan at B1 or above, a storage account with one container, a standard Key Vault, a VNet with an integration subnet delegated to App Service, a separate endpoint subnet and a small runner subnet, plus the three private DNS zones. The app package is a health route and one write route, nothing more.

Setup. Two roots, one state account, one package. The platform root owns the VNet, the zones and the links. The workload root owns the plan, app, identity, storage, vault, endpoints and grants, and consumes the zone ids as variables. Keep the ops scope out of both, because it has to survive them.

StageActionPass condition
Preflightcheck providers, quota, role permission and budgetevery prerequisite row has a yes
Platform applycreate network, zones and linkszones resolve nothing yet, as expected
Workload applycreate app, identity, data, endpoints and grantsapp reports a version, no public address in use
Positive proofrun P1 to P4 from the runnerversion, write, secret and resolution all pass
Negative proofrun N1 to N6 from the two networkseach signal names the intended gate
Promotionapprove both digests, apply the saved plan onceversion route matches the record
Failure and recoverybreak the zone link, observe, restore, reconcileone-link plan, then no-change plans

The runbook, in order. Each step leaves an artifact; if a step produces nothing you can attach, it did not happen.

  1. Record the baseline. Capture the provider versions, the region, the plan SKU, the ceiling and the names you will use. Confirm the provider registrations and the quota before the first plan.
  2. Apply the platform root. Create the VNet, the three subnets, the three zones and one link per zone. Delegate the integration subnet to App Service, and leave the endpoint subnet with no delegation.
  3. Apply the workload root. Create the plan and app with public access disabled, attach the identity, create the storage account with public access disabled, create the container, create the vault with RBAC authorization, then add the endpoints and the zone groups.
  4. Grant and wait. Add the blob data role on the container and the secrets role on the vault, then wait for propagation before the first data call. Record the assignment time, because the wait is part of the test.
  5. Prove the positives. From the runner, resolve the three names, call the version route, write and read one object, and read the secret. Keep the resolver output and the operation ids.
  6. Prove the public refusal. From outside the VNet, request the app hostname, the blob endpoint and the vault endpoint. Expect three refusals with different bodies, and record the source network for each.
  7. Prove the permission boundary. Remove the blob data role, repeat the exact write, and capture the permission error. Restore the role, wait, and repeat the write.
  8. Prove the DNS boundary. Remove the blob zone link in configuration, apply, then resolve and attempt a write. Record the public address and the refusal from the public endpoint, then restore the link and repeat until resolution is private again.
  9. Promote. Build the package once, hash it, store it under an immutable name, save the plan, hash the plan, approve both, apply the saved plan, and deploy the same digest. Confirm the version route reports it.
  10. Break, recover, reconcile, clean. Delete the zone link in the portal as the controlled failure, so the drift is undeclared, follow the timeline, apply the platform root to restore it, then run a no-change plan in all three scopes. Finish with the cleanup inventory.

Expected observation. A sequence, not a duration: three private names resolving inside, three refusals outside, one successful write that turns into a permission error when the role is removed, a public address and a refusal when the link is removed, a version route that matches the approved digest, and a platform plan with exactly one link to add before recovery.

Failure checks. The review fails if the app is reachable from the internet, if the public refusal is a timeout rather than a documented refusal, if the write still succeeds after the role is removed, if the plan digest changes between approval and apply, if the version route reports a digest the record does not contain, if the workload plan changes during the DNS incident, or if any scope still shows a diff at the end.

Cost boundary. One B1 plan, three private endpoints, three zones and links, one storage account with one container, one standard vault and capped log ingestion, against a ceiling of one hundred US dollars per month in one region at list price. The runner exists only for the test window. Confirm current pricing in your region and currency before the apply; the ceiling is a decision, and the alert at eighty percent is how it is enforced.

Cleanup order. Destroy the workload root first, then the platform root, and leave the ops scope until the rollback window closes. Check the endpoint count, the role assignments, the zone records and the soft-deleted vault name, then remove the artifact and state containers and the budget alert. Keep the plan and package digests after the infrastructure is gone.

Evidence to keep. D1 to D6, the provider versions, both plan digests, the package digest, the three resolver outputs, the refusals with their source networks, the permission error, the DNS timeline, the three final no-change plans, the cleanup inventory and the cost actual against the ceiling. Keep the evidence; delete the credentials.

References (verified 6 November 2026):

  • azurerm_linux_web_app: https://registry.terraform.io/providers/hashicorp/azurerm/5.13.0/docs/resources/linux_web_app
  • azurerm_private_endpoint: https://registry.terraform.io/providers/hashicorp/azurerm/5.13.0/docs/resources/private_endpoint
  • App Service private endpoints: https://learn.microsoft.com/en-us/azure/app-service/networking/private-endpoint
  • Private endpoint DNS zones: https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns
  • Storage private endpoints: https://learn.microsoft.com/en-us/azure/storage/common/storage-private-endpoints
  • Key Vault RBAC: https://learn.microsoft.com/en-us/azure/key-vault/general/rbac-guide

A private application is a set of owned objects with proof at each gate. The project passes when a reviewer can name the owner of every object, see the evidence for every acceptance row, replay the promotion from its two digests, and watch one controlled failure recover without a role change. That is a stronger result than a green apply, and it is the result this capstone asks you to deliver.