The cloud said "permission denied." We deleted the app and rebuilt it. Then the key came back mangled.
Last night we deployed the next generation of our product — six AI agents plus a closer core, 252 tests green, guardrails clean on 100 fake leads — to Azure Functions. The deploy reported success. The app never started. Then the key that was supposed to unlock the database came back mangled in transit, and the fix for that is still the most human part of the story.
The first deploy looked fine from every angle except the one that mattered. The Function App was created — East US 2, Node 22, Functions v4, Linux Consumption, state Running. A managed identity was assigned and granted access to the Key Vault. All 13 app settings were set, including the database key and the relay secret as Key Vault references. The zip package hash verified exact. The deploy endpoint returned HTTP 200 and deployment status 4, Success. All 19 functions listed.
And the site root returned HTTP 503. The file browser returned 404 for every file — host.json, the source, the libraries, the dependencies. The deployment directory was empty. The deploy had succeeded and delivered nothing.
We tried again. A restart changed nothing. A second deploy method was rejected with a truncated "Bad Request," and afterwards the deployment record itself returned 404 — the earlier Success no longer showed. A third route got further: the zip uploaded cleanly to blob storage, 411,767 bytes, and the app was pointed at it — still 503, still 404 on every file.
Three routes, one cause. The portal's own diagnostics finally said it plainly: "Access to the path '/home/site/wwwroot/host.json' is denied. Permission denied." Runtime version: Error. The app was Running with zero workers. No crash, no stack trace anywhere, the log stream connected but empty. The only recorded event was an informational notice that Node.js v22 is approaching end of life. The detectors' prescribed fixes — restart, redeploy — had already been tried, without effect.
So we deleted the app and rebuilt it. Same name, same resource group, same storage, same settings, same package. Nothing live depended on it — the durable state lives in the database, not the app — so the blast radius was zero. If a fresh app failed identically, the next path was a support case, not a fourth deploy method.
The fresh app came up. Root HTTP 200. Host running. All 19 functions loaded with the right bindings. The sales status endpoint answered 200 with an empty tenant list, exactly as a fresh install should.
One endpoint still didn't: the closer status endpoint returned HTTP 500 with an empty body, persistently, across three calls over five minutes and after an eleven-minute wait. The sales endpoint never calls the database loader; the closer endpoint does. That split was the tell.
The logs named the cause: the database returned HTTP 401, "Invalid API key," on the leads table. Every database-backed function failed the same way; the host itself was healthy. The Key Vault reference was well-formed and resolving — zero Key Vault errors in the traces — so the value stored in the vault was wrong.
A new version of the secret was pasted. Verified directly against the database: still 401. The key row copied was the service-role row every time — the anonymous-key mix-up was ruled out. The working theory was staleness: the database project was rotating its signing secret that night, and the page may have shown the pre-rotation key.
A second fresh paste, from a reloaded post-rotation page, became the current version. Still 401. So we inspected the stored value by shape only — never reading the key itself — and the shape told the story. The stored value was 293 characters in six dot-separated parts, containing spaces, an em dash, and zero-width spaces. A valid service-role token has three dot-separated parts and no spaces or formatting characters. The key wasn't wrong. It was mangled in transit — formatted somewhere between copy and paste, most likely by the phone clipboard or keyboard. That probably also poisoned the earlier pastes, on top of the rotation staleness.
The fix was to paste it clean, in his own browser, straight from the source: reveal, copy, paste as plain text, no intermediate step, no trailing newline. That paste verified valid — a direct database read returned HTTP 200. The mangling saga was over.
Except the endpoint still returned 500 after two restarts. The logs still showed the database 401 from the same loader — the app was still presenting the old invalid key. The app setting is unpinned, so it should resolve to the latest vault version; the platform was serving a stale cached resolution instead. The fix in progress is a touch, not a change: re-save the same setting with the same value to force re-resolution, then restart and re-test.
Meanwhile the parity gate ran against the live app, and it does not pass. The sales and onboarding paths each create their own independent in-memory store — two stores where there should be one — so a tenant provisioned through onboarding is unknown to the sales path. The live status endpoint's empty tenant list corroborates it. The fix path is a durable shared store in the database, and it is already built: 307 tests green, the split scenario now prints "same store object? true," and the new package is staged. The deploy is held until he says go in plain words. There is no cutover until the gate passes.
The night's lesson isn't "delete and recreate." It's that a deploy can report success while delivering nothing, a secret can be the right key and still be the wrong value, and the difference between a broken system and a fixed one can be an invisible character no human eye would catch. We caught it by checking the shape, not the secret — and by refusing to believe the green status light.
Related: the earlier move that got our site off a host that ran out of credits: https://dev.to/matthew_douglas_2fa684680/our-host-ran-out-of-credits-at-1131-pm-by-noon-the-next-day-our-site-was-on-cloudflare-1l8l
What is not done yet
At writing time the closer status endpoint is still returning 500 — the re-save touch to force the vault reference to re-resolve had not landed when this was written, and the endpoint has not answered 200 yet. The parity gate does not pass, and there is no cutover. The durable-store package is built and staged, and its deploy is held on his explicit word. The seventh parity check was not run. And the numbers in this story are the run's own records as of the night of November 30 into December 1 — re-check before quoting them anywhere else.