NousResearch/hermes-agent · error · ImportError
The 'azure-identity' package is required for Azure AI Foundr
Error message
The 'azure-identity' package is required for Azure AI Foundry Entra ID authentication. {exc} What it means
azure.identity is missing and the lazy-install attempt via tools.lazy_deps.ensure(_AZURE_IDENTITY_FEATURE, prompt=False) raised FeatureUnavailable — meaning the runtime context (no interactivity, no network for install, or feature disabled) cannot auto-install it. The original FeatureUnavailable message is appended so the precise reason is visible.
Source
Thrown at agent/azure_identity_adapter.py:94
package is missing and lazy installs are disabled.
"""
try:
import azure.identity as _ai
return _ai
except ImportError:
try:
from tools.lazy_deps import ensure, FeatureUnavailable
except ImportError as exc:
raise ImportError(
"The 'azure-identity' package is required for Azure AI "
"Foundry Entra ID authentication. Install it with: "
"pip install azure-identity"
) from exc
try:
ensure(_AZURE_IDENTITY_FEATURE, prompt=False)
except FeatureUnavailable as exc:
raise ImportError(
"The 'azure-identity' package is required for Azure AI "
"Foundry Entra ID authentication. " + str(exc)
) from exc
# Retry import after lazy install.
import azure.identity as _ai # noqa: WPS440
return _ai
def reset_credential_cache() -> None:
"""Clear the cached ``DefaultAzureCredential``. Used by tests and
profile switches.
Defensive against tests that ``monkeypatch.setattr`` over
``build_credential`` with a plain (non-lru-cached) function — those
won't expose ``cache_clear()`` until pytest reverts the patch.
"""
cache_clear = getattr(build_credential, "cache_clear", None)View on GitHub (pinned to c896c09c42)
Solutions
- Pre-install in the runtime's environment: pip install azure-identity.
- If installs are blocked, enable network/permission for the lazy-dep feature or install the requirement into the image.
- Read the appended FeatureUnavailable text — it states whether it was disabled by config or failed to install.
Example fix
pip install azure-identity
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib.util
if importlib.util.find_spec("azure.identity") is None:
raise SystemExit("azure-identity required — install it in the image (lazy installs are disabled here)") Try / catch
try:
_import_azure_identity()
except ImportError as e:
if "azure-identity" in str(e):
log.error("pre-install azure-identity; lazy install unavailable: %s", e)
raise Prevention
- Pre-install optional deps in non-interactive/offline runtimes; never rely on lazy installs there.
- Bake azure-identity into container images for Foundry deployments.
When it happens
Trigger: Azure Foundry + Entra auth selected in a non-interactive or offline runtime where lazy dependency installation is disabled/unavailable (agent/azure_identity_adapter.py:94).
Common situations: Gateway/cron/daemon context with prompt=False; offline machine; CI environment blocking pip installs.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- The 'anthropic' package is required for Azure Foundry Anthro
- The 'azure-identity' package is required for Azure AI Foundr
- token provider returned empty value
- no usable api_key / token provider
- httpx is required for Entra ID bearer auth on Microsoft Foun
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/4e6282db038cbbf1.
Report an issue: GitHub.