{"record":{"id":"aeb0ce5d069013ee","repo":"PrefectHQ/fastmcp","slug":"feature-requires-the-azure-extra-install-with","errorCode":null,"errorMessage":"{feature} requires the `azure` extra. Install with: pip install 'fastmcp[azure]'","messagePattern":"(.+?) requires the `azure` extra\\. Install with: pip install 'fastmcp\\[azure\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/auth/providers/azure.py","lineNumber":815,"sourceCode":"        prefixed = []\n        for scope in effective_scopes:\n            if scope in OIDC_SCOPES or \"://\" in scope or \"/\" in scope:\n                prefixed.append(scope)\n            else:\n                prefixed.append(f\"{self._identifier_uri}/{scope}\")\n        return prefixed\n\n\n# --- Dependency injection support ---\n# These require fastmcp[azure] extra for azure-identity\n\n\ndef _require_azure_identity(feature: str) -> None:\n    \"\"\"Raise ImportError with install instructions if azure-identity is not available.\"\"\"\n    try:\n        import azure.identity  # noqa: F401\n    except ImportError as e:\n        raise ImportError(\n            f\"{feature} requires the `azure` extra. \"\n            \"Install with: pip install 'fastmcp[azure]'\"\n        ) from e\n\n\ndef _find_azure_provider(auth: AuthProvider | None) -> AzureProvider | None:\n    \"\"\"Extract an AzureProvider from an auth provider, unwrapping MultiAuth if needed.\"\"\"\n    if isinstance(auth, AzureProvider):\n        return auth\n\n    if isinstance(auth, MultiAuth) and isinstance(auth.server, AzureProvider):\n        return auth.server\n\n    return None\n\n\nclass _EntraOBOToken(Dependency[str]):\n    \"\"\"Dependency that performs OBO token exchange for Microsoft Entra.","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/auth/providers/azure.py#L797-L833","documentation":"OBO features (EntraOBOToken, get_obo_credential) depend on the optional azure-identity package. FastMCP keeps it out of core dependencies; _require_azure_identity probes the import and raises ImportError with install instructions when it's absent, chaining the original ImportError.","triggerScenarios":"Entering EntraOBOToken or calling get_obo_credential in an environment where fastmcp was installed without the [azure] extra (azure.identity import fails).","commonSituations":"Deploying to a fresh container/Lambda with only `pip install fastmcp`; CI installs from a lock file generated without the extra; local dev has azure-identity but production doesn't.","solutions":["Install the extra: pip install 'fastmcp[azure]' (or add azure-identity to your requirements).","Update your dependency manifest (pyproject/requirements/uv add 'fastmcp[azure]') so deployments include it.","Rebuild/redeploy the container image after adding the dependency."],"exampleFix":"// before\npip install fastmcp\n// after\npip install \"fastmcp[azure]\"","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"azure.identity\") is None:\n    raise SystemExit(\"Install with: pip install 'fastmcp[azure]'\")","typeGuard":null,"tryCatchPattern":"try:\n    async with EntraOBOToken(scopes=[\"api\"]) as t:\n        ...\nexcept ImportError as e:\n    logger.error(\"azure-identity missing; install fastmcp[azure]\")\n    raise","preventionTips":["Add 'fastmcp[azure]' to pyproject/requirements, not bare fastmcp","Verify optional extras resolve in CI with a clean install","Keep dev and production dependency manifests in sync"],"tags":["python","azure","missing-dependency","importerror"],"backgroundTag":"missing-optional-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}