feat(azure-foundry): add Microsoft Entra ID auth

Use azure-identity DefaultAzureCredential for keyless Foundry auth.

Preserve refreshable callable credentials through OpenAI and Anthropic client paths.

Add setup, doctor, auth status, docs, and tests for Entra auth.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
glennc 2026-05-15 14:36:18 -07:00 committed by Teknium
parent 457fa913b8
commit 9df9816dab
38 changed files with 3772 additions and 122 deletions

View file

@ -862,13 +862,32 @@ class BatchRunner:
"last_updated": None
}
# Prepare configuration for workers
# Prepare configuration for workers.
#
# ``self.api_key`` may be a zero-arg callable (Azure Foundry Entra ID
# bearer provider returned by ``agent.azure_identity_adapter``). Such
# closures are not safely picklable across the multiprocessing.Pool
# boundary. Drop the callable here and let each worker rebuild its
# own provider via ``resolve_runtime_provider()``, which reads
# ``model.auth_mode`` from ``config.yaml`` and constructs a fresh
# token provider in the worker process (azure-identity caches
# in-process so each worker gets its own short-lived cache).
if callable(self.api_key) and not isinstance(self.api_key, str):
worker_api_key = None
print(
" Detected Entra ID bearer provider — workers will rebuild "
"credentials from config.yaml in each process.",
flush=True,
)
else:
worker_api_key = self.api_key
config = {
"distribution": self.distribution,
"model": self.model,
"max_iterations": self.max_iterations,
"base_url": self.base_url,
"api_key": self.api_key,
"api_key": worker_api_key,
"verbose": self.verbose,
"ephemeral_system_prompt": self.ephemeral_system_prompt,
"log_prefix_chars": self.log_prefix_chars,