FEAT: Inline Container App secret + KV lockdown for GUI deployments#1721
Open
varunj-msft wants to merge 1 commit into
Open
FEAT: Inline Container App secret + KV lockdown for GUI deployments#1721varunj-msft wants to merge 1 commit into
varunj-msft wants to merge 1 commit into
Conversation
Contributor
Author
|
@romanlutz tagging for review! cc @behnam-o |
romanlutz
approved these changes
May 12, 2026
| "keyVaultResourceId": {"value": os.environ["KEY_VAULT_RESOURCE_ID"]}, | ||
| "acrResourceId": {"value": os.environ["ACR_RESOURCE_ID"]}, | ||
| "enablePrivateEndpoint": {"value": parse_bool("ENABLE_PRIVATE_ENDPOINT")}, | ||
| "enableOtel": {"value": parse_bool("ENABLE_OTEL")}, |
Contributor
There was a problem hiding this comment.
Are we doing otel? We should at some point, just didn't realize it's part of this PR
| PARAMS_FILE="$(mktemp --suffix=.parameters.json)" | ||
| trap 'rm -f "$PARAMS_FILE"' EXIT | ||
|
|
||
| python3 - <<'PY' > "$PARAMS_FILE" |
Contributor
There was a problem hiding this comment.
Does this need to be an inline script? Could it just be in the repo somewhere (scripts dir?)
| --name env-global \ | ||
| --file ./updated.env | ||
| # Pre-flight: fail fast if the file is missing | ||
| test -f ./updated.env || { echo "ERROR: ./updated.env not found"; exit 1; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrates the CoPyRIT GUI from a Key Vault
secretRefruntime model to an inline Container App secret, which lets us fully lock down the per-instance Key Vault for SFI/NS221 compliance without breaking the running app.Why this approach:
The S360 alert on
copyrit-demo-kvrequirespublicNetworkAccess=Disabled. I tested the fix (pna=Disabled + defaultAction=Deny + bypass=AzureServices) on a throwaway and it broke the deploy at container startup withunable to fetch secret 'env-file' using Managed identity. Root cause: Azure Container Apps is not on Key Vault's "trusted services" allowlist, so KV-backed secret references fail at runtime against a locked-down vault. App Service is on that list; ACA isn't.The fix is to remove the runtime KV dependency entirely. The
.envcontent is now passed inline to the Container App via the BicepenvFileContents@secure()parameter and stored in ACA's encrypted secrets store. The KV is still created, populated with the.envas backup/audit, and locked down, but never read at runtime.Validated end-to-end on a throwaway (
kvtest5in centralus): deploy succeeded, KV ended up locked down, container app came up, login worked, chat worked.Files touched (9):
infra/main.bicep+infra/main.json: replacedenvSecretName(KV ref) with@secure() envFileContents(inline value).infra/deploy_instance.py: applies SFI lockdown to KV after backup secret upload; removed the now-unneeded KV Secrets User MI grant; passesenvFileContentsvia temp parameters JSON file (avoidspsexposure).gui-deploy.yml: same temp-parameters-file pattern; strict validation that fails loudly ifenablePrivateEndpoint,enableOtel, orenvFileContentsADO variables are unresolved.infra/parameters.example.json+infra/parameters.demo.json: switched fromenvSecretNametoenvFileContents; added warnings about the@filesilent-fallback footgun.infra/README.md+infra/DEPLOY_NEW_INSTANCE.md: rewrote secret-rotation guidance (useaz containerapp secret set --secrets env-file=@./updated.envwith pre-flighttest -fcheck; explicitly anti-patterns the unsafe alternatives); both bash and PowerShell examples.docker/start.sh: 1-line comment update.What this does NOT do:
copyrit-demodeployment. It still runs the OLD pattern (KV reference). The S360 alert oncopyrit-demo-kvis not cleared by this PR.Follow-up after merge:
envFileContentsSECURE variable to ADO library variable groupscopyrit-gui-testandcopyrit-gui-prod. Without it, the next pipeline run fails fast with a clear error (the new strict validation catches it).copyrit-demowith the new inline-secret model (this implies a brief revision cutover for active users).copyrit-demo-kvto clear the S360 alert.Tests and Documentation
No code-level unit tests added - the change is to deployment infrastructure (Bicep, ADO pipeline, deploy script). Validation done:
kvtest5(centralus): full deploy succeeded; container started; chat worked end-to-end against the locked-down KV pattern.az deployment group validateagainst realcopyrit-demoresource IDs: succeeded.pre-commit runon all 9 modified files: clean.az bicep build: zero new warnings.infra/main.jsonmatches compiledinfra/main.bicep.JupyText not applicable - no
doc/changes.