{"record":{"id":"971ed75d1247b177","repo":"NousResearch/hermes-agent","slug":"the-azure-identity-package-is-required-for-azure","errorCode":null,"errorMessage":"The 'azure-identity' package is required for Azure AI Foundry Entra ID authentication. Install it with: pip install azure-identity","messagePattern":"The 'azure-identity' package is required for Azure AI Foundry Entra ID authentication\\. Install it with: pip install azure-identity","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"agent/azure_identity_adapter.py","lineNumber":85,"sourceCode":"        return True\n    except Exception:\n        return False\n\n\ndef _require_azure_identity():\n    \"\"\"Import ``azure.identity``, lazy-installing it if allowed.\n\n    Raises ``ImportError`` with a clear actionable message when the\n    package is missing and lazy installs are disabled.\n    \"\"\"\n    try:\n        import azure.identity as _ai\n        return _ai\n    except ImportError:\n        try:\n            from tools.lazy_deps import ensure, FeatureUnavailable\n        except ImportError as exc:\n            raise ImportError(\n                \"The 'azure-identity' package is required for Azure AI \"\n                \"Foundry Entra ID authentication. Install it with: \"\n                \"pip install azure-identity\"\n            ) from exc\n\n        try:\n            ensure(_AZURE_IDENTITY_FEATURE, prompt=False)\n        except FeatureUnavailable as exc:\n            raise ImportError(\n                \"The 'azure-identity' package is required for Azure AI \"\n                \"Foundry Entra ID authentication. \" + str(exc)\n            ) from exc\n\n        # Retry import after lazy install.\n        import azure.identity as _ai  # noqa: WPS440\n        return _ai\n\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/azure_identity_adapter.py#L67-L103","documentation":"Raised while importing azure.identity for Azure AI Foundry Entra ID auth: the import failed AND the tools.lazy_deps module itself could not be imported, so the lazy-install escape hatch is unavailable. The adapter deliberately surfaces an actionable ImportError instead of a bare ModuleNotFoundError.","triggerScenarios":"Selecting the Azure Foundry provider with Entra auth in an environment where azure-identity is absent and Hermes' tools.lazy_deps is not importable (broken install, partial venv, exotic packaging).","commonSituations":"Broken/partial pip install of hermes-agent; running from a source checkout with unresolved deps; a stripped-down container.","solutions":["pip install azure-identity in the active venv.","Reinstall/repair hermes-agent so tools.lazy_deps is importable (pip install -e . from the repo root).","Verify the correct Python interpreter/venv is active (which python; pip -V)."],"exampleFix":"pip install azure-identity","handlingStrategy":"validation","validationCode":"try:\n    import azure.identity  # noqa\n    ok = True\nexcept ImportError:\n    ok = False\n# and ensure hermes install is intact\nimport tools.lazy_deps  # noqa — should not raise","typeGuard":null,"tryCatchPattern":"try:\n    from agent.azure_identity_adapter import _import_azure_identity\n    _import_azure_identity()\nexcept ImportError as e:\n    if \"azure-identity\" in str(e):\n        run(\"pip install azure-identity\")","preventionTips":["Install optional provider extras up front when you plan to use them.","Prefer pip install -e '.[all-relevant-extras]' over partial installs.","Validate the venv with `hermes doctor`-style import checks after install."],"tags":["azure","entra-id","import","dependencies"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}