fix(s41): pass required credential in AzureFoundryBackend.create_chat_client

This commit is contained in:
Kjell Tore Guttormsen 2026-07-15 11:18:40 +02:00
commit 82c85d5e7c
4 changed files with 27 additions and 2 deletions

View file

@ -103,8 +103,17 @@ class AzureFoundryBackend:
endpoint = os.environ.get("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT")
if not endpoint:
raise ValueError("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT is required for the AZURE profile")
# Credential resolves lazily via Azure DefaultAzureCredential (az login / MI).
return FoundryChatClient(project_endpoint=endpoint, model=model)
# FoundryChatClient REQUIRES an explicit credential (verified against agent-framework-foundry
# 1.8.2 — it raises ``ValueError`` without one; there is NO lazy DefaultAzureCredential
# default). Lazy import so the LOCAL path never pulls azure.identity. AzureCliCredential is
# the documented, friction-minimal path on a non-Azure host — constructing it acquires NO
# token (``az login`` is the operator's manual step), so this is not auto-login. Recipe:
# docs/2026-07-15-foundry-auth-recipe.md.
from azure.identity.aio import AzureCliCredential
return FoundryChatClient(
project_endpoint=endpoint, model=model, credential=AzureCliCredential()
)
class LocalBackend: