Skip to content

fix(cli): align Azure provider env var with docs (prefer AZURE_OPENAI_API_KEY, accept legacy AZURE_OPENAI_KEY) - #23

Merged
manojp99 merged 1 commit into
mainfrom
fix/azure-env-var-naming
May 29, 2026
Merged

fix(cli): align Azure provider env var with docs (prefer AZURE_OPENAI_API_KEY, accept legacy AZURE_OPENAI_KEY)#23
manojp99 merged 1 commit into
mainfrom
fix/azure-env-var-naming

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

What. Aligns the CLI's Azure provider detection with the rest of the project. The README, the architecture presentation, the cheatsheet, the upstream amplifier-module-provider-azure-openai module, and the Azure OpenAI Python SDK all spell the credential as AZURE_OPENAI_API_KEY, but provider_detect and provider_sources were the only place still honoring the older AZURE_OPENAI_KEY spelling. After this change the CLI prefers AZURE_OPENAI_API_KEY, keeps detection precedence intact (ANTHROPIC_API_KEYOPENAI_API_KEYAZURE_OPENAI_API_KEYOLLAMA_HOST), and accepts AZURE_OPENAI_KEY as a deprecated legacy alias that triggers a one-time [WARN] on stderr.

Why. Surfaced by a reality check on amplifier-agent: a user following the documented setup (export AZURE_OPENAI_API_KEY=…) would have amplifier-agent doctor report "provider not configured" because provider_detect only checked AZURE_OPENAI_KEY. Dual-accept was chosen over a clean rename because the upstream Azure provider module itself already accepts both spellings (preferring AZURE_OPENAI_API_KEY, falling back to AZURE_OPENAI_KEY — see amplifier_module_provider_azure_openai/__init__.py lines 119–120), so mirroring that behavior in the CLI fixes the user-facing bug without breaking anyone currently using the legacy var, and gives us a one-release deprecation window. The legacy alias and its warning are trivially removable in a future PR. Separate from PR #22 (version-info-and-error-message).

How verified. python_check (ruff + pyright + stub-check + format) is clean on all 8 changed .py files. Targeted pytest on the 5 touched test files: 53 passed (including 2 new tests covering the legacy-fallback path and the preferred-over-legacy precedence). Full pytest -m "not integration" shows the same 23 pre-existing failures that exist on origin/main — no new failures introduced, +2 passing count from the new tests. Manual: with AZURE_OPENAI_API_KEY=fake set and the other provider vars unset, amplifier-agent doctor now reports [ OK ] provider: azure-openai (no warning); with the legacy AZURE_OPENAI_KEY set, doctor still detects Azure and emits the [WARN] AZURE_OPENAI_KEY is deprecated… line on stderr exactly once.

…_API_KEY, accept legacy AZURE_OPENAI_KEY)

Aligns the CLI's Azure provider detection with the rest of the project. The README,
architecture presentation, cheatsheet, upstream amplifier-module-provider-azure-openai,
and Azure OpenAI Python SDK all use AZURE_OPENAI_API_KEY, but the CLI was only honoring
AZURE_OPENAI_KEY. After this change, the CLI prefers AZURE_OPENAI_API_KEY, accepts
AZURE_OPENAI_KEY as a deprecated legacy alias with a one-time [WARN] on stderr,
and preserves detection precedence (ANTHROPIC_API_KEY > OPENAI_API_KEY > AZURE_OPENAI_API_KEY > OLLAMA_HOST).

Mirrors the upstream Azure provider module's dual-accept pattern (see __init__.py lines 119-120),
which already prefers AZURE_OPENAI_API_KEY and falls back to AZURE_OPENAI_KEY.

Verification: python_check clean on all 8 changed .py files, 53 tests pass on targeted
test suite, full pytest shows same 23 pre-existing failures as origin/main (+2 new tests
passing, no new failures). Manual verification confirms detection works with both spellings,
legacy fallback triggers deprecation warning.

Separate from PR #22 (version-info-and-error-message).

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@manojp99
manojp99 merged commit 5bec49e into main May 29, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant