deploy.sh: interactive subscription/tenant mismatch prompt¶
Motivation¶
./deploy.sh previously errored out hard whenever the active Azure CLI
subscription/tenant differed from the values stored in
.azure/<env>/.env (typical after az login against a different
subscription on the same workstation). The error message printed two
remediation paths but required the operator to manually copy/paste
commands and rerun the script — a friction point that confused the user
in the May 26 session.
User-facing change¶
When the script detects a subscription or tenant mismatch in an interactive TTY, it now prints both contexts and asks:
How would you like to proceed?
1) Use the active Azure CLI context — retarget the azd environment to it (sets ELB_ALLOW_AZD_ENV_RETARGET=true)
2) Keep the azd environment target — switch Azure CLI to match it (runs az account set [+ az login --tenant])
3) Abort and let me fix it manually
Enter choice [1/2/3] (default 3):
- Option 1 (the natural choice when the operator just ran
az loginagainst the intended subscription) setsELB_ALLOW_AZD_ENV_RETARGET=truein the current process; the downstreamazd env set ... AZURE_SUBSCRIPTION_IDcalls then overwrite.azure/<env>/.envto match the active Azure CLI context (the documented retarget behaviour). - Option 2 runs
az login --tenant <existing-tenant>(only when the tenant differs) followed byaz account set --subscription <existing-sub>, then re-readsaz account showand continues. The existingazd auth login --check-statusblock immediately afterwards handles re-logging azd when needed. - Option 3 (default) prints the same manual remediation block the script used to emit and exits 1.
Non-interactive shells (no TTY on stdin/stdout, e.g. CI) skip the prompt
and behave exactly like before: print the remediation block and exit 1.
ELB_ALLOW_AZD_ENV_RETARGET=true still skips the entire check, same as
before.
API / IaC diff summary¶
- deploy.sh: replaced the two separate
subscription/tenant mismatch error blocks with a single combined
detection + interactive prompt. Help text for
ELB_ALLOW_AZD_ENV_RETARGETupdated to describe the new prompt and the non-interactive fallback.
No backend, frontend, or Bicep changes.
Validation¶
bash -n deploy.sh— syntax clean.- Manual flow inspection: prompt branches handle both
subscription-only andsubscription + tenantmismatches; option 1'saz account setverifies the switch took effect before continuing.